Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields | Protected Member Functions | Protected Attributes | Static Protected Attributes
Zend_Cache_Core Class Reference
Inheritance diagram for Zend_Cache_Core:
Core Zend_Cache_Frontend_Capture Zend_Cache_Frontend_Class Zend_Cache_Frontend_File Zend_Cache_Frontend_Function Zend_Cache_Frontend_Output Zend_Cache_Frontend_Page

Public Member Functions

 __construct ($options=array())
 
 setConfig (Zend_Config $config)
 
 setBackend (Zend_Cache_Backend $backendObject)
 
 getBackend ()
 
 setOption ($name, $value)
 
 getOption ($name)
 
 setLifetime ($newLifetime)
 
 load ($id, $doNotTestCacheValidity=false, $doNotUnserialize=false)
 
 test ($id)
 
 save ($data, $id=null, $tags=array(), $specificLifetime=false, $priority=8)
 
 remove ($id)
 
 clean ($mode='all', $tags=array())
 
 getIdsMatchingTags ($tags=array())
 
 getIdsNotMatchingTags ($tags=array())
 
 getIdsMatchingAnyTags ($tags=array())
 
 getIds ()
 
 getTags ()
 
 getFillingPercentage ()
 
 getMetadatas ($id)
 
 touch ($id, $extraLifetime)
 

Data Fields

const BACKEND_NOT_SUPPORTS_TAG = 'tags are not supported by the current backend'
 
const BACKEND_NOT_IMPLEMENTS_EXTENDED_IF = 'Current backend doesn\'t implement the Zend_Cache_Backend_ExtendedInterface, so this method is not available'
 

Protected Member Functions

 _validateIdOrTag ($string)
 
 _validateTagsArray ($tags)
 
 _loggerSanity ()
 
 _log ($message, $priority=4)
 
 _id ($id)
 

Protected Attributes

 $_backend = null
 
 $_options
 
 $_specificOptions = array()
 
 $_extendedBackend = false
 
 $_backendCapabilities = array()
 

Static Protected Attributes

static $_directivesList = array('lifetime', 'logging', 'logger')
 

Detailed Description

Definition at line 28 of file Core.php.

Constructor & Destructor Documentation

◆ __construct()

__construct (   $options = array())

Constructor

Parameters
array | Zend_Config$optionsAssociative array of options or Zend_Config instance
Exceptions
Zend_Cache_Exception
Returns
void

Definition at line 137 of file Core.php.

138  {
139  if ($options instanceof Zend_Config) {
140  $options = $options->toArray();
141  }
142  if (!is_array($options)) {
143  Zend_Cache::throwException("Options passed were not an array"
144  . " or Zend_Config instance.");
145  }
146  foreach ($options as $name => $value) {
147  $this->setOption($name, $value);
148  }
149  $this->_loggerSanity();
150  }
setOption($name, $value)
Definition: Core.php:211
$value
Definition: gender.phtml:16
static throwException($msg, Exception $e=null)
Definition: Cache.php:205
if(!isset($_GET['name'])) $name
Definition: log.php:14

Member Function Documentation

◆ _id()

_id (   $id)
protected

Make and return a cache id

Checks 'cache_id_prefix' and returns new id with prefix or simply the id if null

Parameters
string$idCache id
Returns
string Cache id (with or without prefix)

Definition at line 757 of file Core.php.

758  {
759  if (($id !== null) && isset($this->_options['cache_id_prefix'])) {
760  return $this->_options['cache_id_prefix'] . $id; // return with prefix
761  }
762  return $id; // no prefix, just return the $id passed
763  }
$id
Definition: fieldset.phtml:14

◆ _log()

_log (   $message,
  $priority = 4 
)
protected

Log a message at the WARN (4) priority.

Parameters
string$message
Exceptions
Zend_Cache_Exception
Returns
void

Definition at line 737 of file Core.php.

738  {
739  if (!$this->_options['logging']) {
740  return;
741  }
742  if (!(isset($this->_options['logger']) || $this->_options['logger'] instanceof Zend_Log)) {
743  Zend_Cache::throwException('Logging is enabled but logger is not set');
744  }
745  $logger = $this->_options['logger'];
746  $logger->log($message, $priority);
747  }
$message
$logger
static throwException($msg, Exception $e=null)
Definition: Cache.php:205

◆ _loggerSanity()

_loggerSanity ( )
protected

Make sure if we enable logging that the Zend_Log class is available. Create a default log object if none is set.

Exceptions
Zend_Cache_Exception
Returns
void

Definition at line 711 of file Core.php.

712  {
713  if (!isset($this->_options['logging']) || !$this->_options['logging']) {
714  return;
715  }
716 
717  if (isset($this->_options['logger']) && $this->_options['logger'] instanceof Zend_Log) {
718  return;
719  }
720 
721  // Create a default logger to the standard output stream
722  #require_once 'Zend/Log.php';
723  #require_once 'Zend/Log/Writer/Stream.php';
724  #require_once 'Zend/Log/Filter/Priority.php';
725  $logger = new Zend_Log(new Zend_Log_Writer_Stream('php://output'));
726  $logger->addFilter(new Zend_Log_Filter_Priority(Zend_Log::WARN, '<='));
727  $this->_options['logger'] = $logger;
728  }
const WARN
Definition: Log.php:46
$logger

◆ _validateIdOrTag()

_validateIdOrTag (   $string)
protected

Validate a cache id or a tag (security, reliable filenames, reserved prefixes...)

Throw an exception if a problem is found

Parameters
string$stringCache id or tag
Exceptions
Zend_Cache_Exception
Returns
void

Definition at line 670 of file Core.php.

671  {
672  if (!is_string($string)) {
673  Zend_Cache::throwException('Invalid id or tag : must be a string');
674  }
675  if (substr($string, 0, 9) == 'internal-') {
676  Zend_Cache::throwException('"internal-*" ids or tags are reserved');
677  }
678  if (!preg_match('~^[a-zA-Z0-9_]+$~D', $string)) {
679  Zend_Cache::throwException("Invalid id or tag '$string' : must use only [a-zA-Z0-9_]");
680  }
681  }
static throwException($msg, Exception $e=null)
Definition: Cache.php:205

◆ _validateTagsArray()

_validateTagsArray (   $tags)
protected

Validate a tags array (security, reliable filenames, reserved prefixes...)

Throw an exception if a problem is found

Parameters
array$tagsArray of tags
Exceptions
Zend_Cache_Exception
Returns
void

Definition at line 692 of file Core.php.

693  {
694  if (!is_array($tags)) {
695  Zend_Cache::throwException('Invalid tags array : must be an array');
696  }
697  foreach($tags as $tag) {
698  $this->_validateIdOrTag($tag);
699  }
700  reset($tags);
701  }
_validateIdOrTag($string)
Definition: Core.php:670
static throwException($msg, Exception $e=null)
Definition: Cache.php:205

◆ clean()

clean (   $mode = 'all',
  $tags = array() 
)

Clean cache entries

Available modes are : 'all' (default) => remove all cache entries ($tags is not used) 'old' => remove too old cache entries ($tags is not used) 'matchingTag' => remove cache entries matching all given tags ($tags can be an array of strings or a single string) 'notMatchingTag' => remove cache entries not matching one of the given tags ($tags can be an array of strings or a single string) 'matchingAnyTag' => remove cache entries matching any given tags ($tags can be an array of strings or a single string)

Parameters
string$mode
array | string$tags
Exceptions
Zend_Cache_Exception
Returns
boolean True if ok

Definition at line 451 of file Core.php.

452  {
453  if (!$this->_options['caching']) {
454  return true;
455  }
456  if (!in_array($mode, array(Zend_Cache::CLEANING_MODE_ALL,
461  Zend_Cache::throwException('Invalid cleaning mode');
462  }
463  $this->_validateTagsArray($tags);
464 
465  return $this->_backend->clean($mode, $tags);
466  }
const CLEANING_MODE_OLD
Definition: Cache.php:73
const CLEANING_MODE_NOT_MATCHING_TAG
Definition: Cache.php:75
_validateTagsArray($tags)
Definition: Core.php:692
if($exist=($block->getProductCollection() && $block->getProductCollection() ->getSize())) $mode
Definition: grid.phtml:15
const CLEANING_MODE_ALL
Definition: Cache.php:72
static throwException($msg, Exception $e=null)
Definition: Cache.php:205
const CLEANING_MODE_MATCHING_ANY_TAG
Definition: Cache.php:76
const CLEANING_MODE_MATCHING_TAG
Definition: Cache.php:74

◆ getBackend()

getBackend ( )

Returns the backend

Returns
Zend_Cache_Backend backend object

Definition at line 196 of file Core.php.

197  {
198  return $this->_backend;
199  }

◆ getFillingPercentage()

getFillingPercentage ( )

Return the filling percentage of the backend storage

Returns
int integer between 0 and 100

Definition at line 615 of file Core.php.

616  {
617  if (!$this->_extendedBackend) {
618  Zend_Cache::throwException(self::BACKEND_NOT_IMPLEMENTS_EXTENDED_IF);
619  }
620  return $this->_backend->getFillingPercentage();
621  }
static throwException($msg, Exception $e=null)
Definition: Cache.php:205

◆ getIds()

getIds ( )

Return an array of stored cache ids

Returns
array array of stored cache ids (string)

Definition at line 572 of file Core.php.

573  {
574  if (!$this->_extendedBackend) {
575  Zend_Cache::throwException(self::BACKEND_NOT_IMPLEMENTS_EXTENDED_IF);
576  }
577 
578  $ids = $this->_backend->getIds();
579 
580  // we need to remove cache_id_prefix from ids (see #ZF-6178, #ZF-7600)
581  if (isset($this->_options['cache_id_prefix']) && $this->_options['cache_id_prefix'] !== '') {
582  $prefix = & $this->_options['cache_id_prefix'];
583  $prefixLen = strlen($prefix);
584  foreach ($ids as &$id) {
585  if (strpos($id, $prefix) === 0) {
586  $id = substr($id, $prefixLen);
587  }
588  }
589  }
590 
591  return $ids;
592  }
$id
Definition: fieldset.phtml:14
$prefix
Definition: name.phtml:25
static throwException($msg, Exception $e=null)
Definition: Cache.php:205

◆ getIdsMatchingAnyTags()

getIdsMatchingAnyTags (   $tags = array())

Return an array of stored cache ids which match any given tags

In case of multiple tags, a logical OR is made between tags

Parameters
array$tagsarray of tags
Returns
array array of matching any cache ids (string)

Definition at line 542 of file Core.php.

543  {
544  if (!$this->_extendedBackend) {
545  Zend_Cache::throwException(self::BACKEND_NOT_IMPLEMENTS_EXTENDED_IF);
546  }
547  if (!($this->_backendCapabilities['tags'])) {
548  Zend_Cache::throwException(self::BACKEND_NOT_SUPPORTS_TAG);
549  }
550 
551  $ids = $this->_backend->getIdsMatchingAnyTags($tags);
552 
553  // we need to remove cache_id_prefix from ids (see #ZF-6178, #ZF-7600)
554  if (isset($this->_options['cache_id_prefix']) && $this->_options['cache_id_prefix'] !== '') {
555  $prefix = & $this->_options['cache_id_prefix'];
556  $prefixLen = strlen($prefix);
557  foreach ($ids as &$id) {
558  if (strpos($id, $prefix) === 0) {
559  $id = substr($id, $prefixLen);
560  }
561  }
562  }
563 
564  return $ids;
565  }
$id
Definition: fieldset.phtml:14
$prefix
Definition: name.phtml:25
static throwException($msg, Exception $e=null)
Definition: Cache.php:205

◆ getIdsMatchingTags()

getIdsMatchingTags (   $tags = array())

Return an array of stored cache ids which match given tags

In case of multiple tags, a logical AND is made between tags

Parameters
array$tagsarray of tags
Returns
array array of matching cache ids (string)

Definition at line 476 of file Core.php.

477  {
478  if (!$this->_extendedBackend) {
479  Zend_Cache::throwException(self::BACKEND_NOT_IMPLEMENTS_EXTENDED_IF);
480  }
481  if (!($this->_backendCapabilities['tags'])) {
482  Zend_Cache::throwException(self::BACKEND_NOT_SUPPORTS_TAG);
483  }
484 
485  $ids = $this->_backend->getIdsMatchingTags($tags);
486 
487  // we need to remove cache_id_prefix from ids (see #ZF-6178, #ZF-7600)
488  if (isset($this->_options['cache_id_prefix']) && $this->_options['cache_id_prefix'] !== '') {
489  $prefix = & $this->_options['cache_id_prefix'];
490  $prefixLen = strlen($prefix);
491  foreach ($ids as &$id) {
492  if (strpos($id, $prefix) === 0) {
493  $id = substr($id, $prefixLen);
494  }
495  }
496  }
497 
498  return $ids;
499  }
$id
Definition: fieldset.phtml:14
$prefix
Definition: name.phtml:25
static throwException($msg, Exception $e=null)
Definition: Cache.php:205

◆ getIdsNotMatchingTags()

getIdsNotMatchingTags (   $tags = array())

Return an array of stored cache ids which don't match given tags

In case of multiple tags, a logical OR is made between tags

Parameters
array$tagsarray of tags
Returns
array array of not matching cache ids (string)

Definition at line 509 of file Core.php.

510  {
511  if (!$this->_extendedBackend) {
512  Zend_Cache::throwException(self::BACKEND_NOT_IMPLEMENTS_EXTENDED_IF);
513  }
514  if (!($this->_backendCapabilities['tags'])) {
515  Zend_Cache::throwException(self::BACKEND_NOT_SUPPORTS_TAG);
516  }
517 
518  $ids = $this->_backend->getIdsNotMatchingTags($tags);
519 
520  // we need to remove cache_id_prefix from ids (see #ZF-6178, #ZF-7600)
521  if (isset($this->_options['cache_id_prefix']) && $this->_options['cache_id_prefix'] !== '') {
522  $prefix = & $this->_options['cache_id_prefix'];
523  $prefixLen = strlen($prefix);
524  foreach ($ids as &$id) {
525  if (strpos($id, $prefix) === 0) {
526  $id = substr($id, $prefixLen);
527  }
528  }
529  }
530 
531  return $ids;
532  }
$id
Definition: fieldset.phtml:14
$prefix
Definition: name.phtml:25
static throwException($msg, Exception $e=null)
Definition: Cache.php:205

◆ getMetadatas()

getMetadatas (   $id)

Return an array of metadatas for the given cache id

The array will include these keys :

  • expire : the expire timestamp
  • tags : a string array of tags
  • mtime : timestamp of last modification time
Parameters
string$idcache id
Returns
array array of metadatas (false if the cache id is not found)

Definition at line 634 of file Core.php.

635  {
636  if (!$this->_extendedBackend) {
637  Zend_Cache::throwException(self::BACKEND_NOT_IMPLEMENTS_EXTENDED_IF);
638  }
639  $id = $this->_id($id); // cache id may need prefix
640  return $this->_backend->getMetadatas($id);
641  }
$id
Definition: fieldset.phtml:14
static throwException($msg, Exception $e=null)
Definition: Cache.php:205

◆ getOption()

getOption (   $name)

Public frontend to get an option value

Parameters
string$nameName of the option
Exceptions
Zend_Cache_Exception
Returns
mixed option value

Definition at line 236 of file Core.php.

237  {
238  $name = strtolower($name);
239 
240  if (array_key_exists($name, $this->_options)) {
241  // This is a Core option
242  return $this->_options[$name];
243  }
244 
245  if (array_key_exists($name, $this->_specificOptions)) {
246  // This a specic option of this frontend
247  return $this->_specificOptions[$name];
248  }
249 
250  Zend_Cache::throwException("Incorrect option name : $name");
251  }
static throwException($msg, Exception $e=null)
Definition: Cache.php:205
if(!isset($_GET['name'])) $name
Definition: log.php:14

◆ getTags()

getTags ( )

Return an array of stored tags

Returns
array array of stored tags (string)

Definition at line 599 of file Core.php.

600  {
601  if (!$this->_extendedBackend) {
602  Zend_Cache::throwException(self::BACKEND_NOT_IMPLEMENTS_EXTENDED_IF);
603  }
604  if (!($this->_backendCapabilities['tags'])) {
605  Zend_Cache::throwException(self::BACKEND_NOT_SUPPORTS_TAG);
606  }
607  return $this->_backend->getTags();
608  }
static throwException($msg, Exception $e=null)
Definition: Cache.php:205

◆ load()

load (   $id,
  $doNotTestCacheValidity = false,
  $doNotUnserialize = false 
)

Test if a cache is available for the given id and (if yes) return it (false else)

Parameters
string$idCache id
boolean$doNotTestCacheValidityIf set to true, the cache validity won't be tested
boolean$doNotUnserializeDo not serialize (even if automatic_serialization is true) => for internal use
Returns
mixed|false Cached datas

Definition at line 296 of file Core.php.

297  {
298  if (!$this->_options['caching']) {
299  return false;
300  }
301  $id = $this->_id($id); // cache id may need prefix
302  $this->_lastId = $id;
303  $this->_validateIdOrTag($id);
304 
305  $this->_log("Zend_Cache_Core: load item '{$id}'", 7);
306  $data = $this->_backend->load($id, $doNotTestCacheValidity);
307  if ($data===false) {
308  // no cache available
309  return false;
310  }
311  if ((!$doNotUnserialize) && $this->_options['automatic_serialization']) {
312  // we need to unserialize before sending the result
313  return unserialize($data);
314  }
315  return $data;
316  }
_log($message, $priority=4)
Definition: Core.php:737
_validateIdOrTag($string)
Definition: Core.php:670
$id
Definition: fieldset.phtml:14

◆ remove()

remove (   $id)

Remove a cache

Parameters
string$idCache id to remove
Returns
boolean True if ok

Definition at line 421 of file Core.php.

422  {
423  if (!$this->_options['caching']) {
424  return true;
425  }
426  $id = $this->_id($id); // cache id may need prefix
427  $this->_validateIdOrTag($id);
428 
429  $this->_log("Zend_Cache_Core: remove item '{$id}'", 7);
430  return $this->_backend->remove($id);
431  }
_log($message, $priority=4)
Definition: Core.php:737
_validateIdOrTag($string)
Definition: Core.php:670
$id
Definition: fieldset.phtml:14

◆ save()

save (   $data,
  $id = null,
  $tags = array(),
  $specificLifetime = false,
  $priority = 8 
)

Save some data in a cache

Parameters
mixed$dataData to put in cache (can be another type than string if automatic_serialization is on)
string$idCache id (if not set, the last cache id will be used)
array$tagsCache tags
int$specificLifetimeIf != false, set a specific lifetime for this cache record (null => infinite lifetime)
int$priorityinteger between 0 (very low priority) and 10 (maximum priority) used by some particular backends
Exceptions
Zend_Cache_Exception
Returns
boolean True if no problem

Definition at line 348 of file Core.php.

349  {
350  if (!$this->_options['caching']) {
351  return true;
352  }
353  if ($id === null) {
354  $id = $this->_lastId;
355  } else {
356  $id = $this->_id($id);
357  }
358  $this->_validateIdOrTag($id);
359  $this->_validateTagsArray($tags);
360  if ($this->_options['automatic_serialization']) {
361  // we need to serialize datas before storing them
362  $data = serialize($data);
363  } else {
364  if (!is_string($data)) {
365  Zend_Cache::throwException("Datas must be string or set automatic_serialization = true");
366  }
367  }
368 
369  // automatic cleaning
370  if ($this->_options['automatic_cleaning_factor'] > 0) {
371  $rand = rand(1, $this->_options['automatic_cleaning_factor']);
372  if ($rand==1) {
373  // new way || deprecated way
374  if ($this->_extendedBackend || method_exists($this->_backend, 'isAutomaticCleaningAvailable')) {
375  $this->_log("Zend_Cache_Core::save(): automatic cleaning running", 7);
377  } else {
378  $this->_log("Zend_Cache_Core::save(): automatic cleaning is not available/necessary with current backend", 4);
379  }
380  }
381  }
382 
383  $this->_log("Zend_Cache_Core: save item '{$id}'", 7);
384  if ($this->_options['ignore_user_abort']) {
385  $abort = ignore_user_abort(true);
386  }
387  if (($this->_extendedBackend) && ($this->_backendCapabilities['priority'])) {
388  $result = $this->_backend->save($data, $id, $tags, $specificLifetime, $priority);
389  } else {
390  $result = $this->_backend->save($data, $id, $tags, $specificLifetime);
391  }
392  if ($this->_options['ignore_user_abort']) {
393  ignore_user_abort($abort);
394  }
395 
396  if (!$result) {
397  // maybe the cache is corrupted, so we remove it !
398  $this->_log("Zend_Cache_Core::save(): failed to save item '{$id}' -> removing it", 4);
399  $this->_backend->remove($id);
400  return false;
401  }
402 
403  if ($this->_options['write_control']) {
404  $data2 = $this->_backend->load($id, true);
405  if ($data!=$data2) {
406  $this->_log("Zend_Cache_Core::save(): write control of item '{$id}' failed -> removing it", 4);
407  $this->_backend->remove($id);
408  return false;
409  }
410  }
411 
412  return true;
413  }
_log($message, $priority=4)
Definition: Core.php:737
_validateIdOrTag($string)
Definition: Core.php:670
$id
Definition: fieldset.phtml:14
const CLEANING_MODE_OLD
Definition: Cache.php:73
_validateTagsArray($tags)
Definition: Core.php:692
static throwException($msg, Exception $e=null)
Definition: Cache.php:205
clean($mode='all', $tags=array())
Definition: Core.php:451

◆ setBackend()

setBackend ( Zend_Cache_Backend  $backendObject)

Set the backend

Parameters
Zend_Cache_Backend$backendObject
Exceptions
Zend_Cache_Exception
Returns
void

Definition at line 174 of file Core.php.

175  {
176  $this->_backend= $backendObject;
177  // some options (listed in $_directivesList) have to be given
178  // to the backend too (even if they are not "backend specific")
179  $directives = array();
180  foreach (Zend_Cache_Core::$_directivesList as $directive) {
181  $directives[$directive] = $this->_options[$directive];
182  }
183  $this->_backend->setDirectives($directives);
184  if (in_array('Zend_Cache_Backend_ExtendedInterface', class_implements($this->_backend))) {
185  $this->_extendedBackend = true;
186  $this->_backendCapabilities = $this->_backend->getCapabilities();
187  }
188 
189  }
static $_directivesList
Definition: Core.php:100

◆ setConfig()

setConfig ( Zend_Config  $config)

Set options using an instance of type Zend_Config

Parameters
Zend_Config$config
Returns
Zend_Cache_Core

Definition at line 158 of file Core.php.

159  {
160  $options = $config->toArray();
161  foreach ($options as $name => $value) {
162  $this->setOption($name, $value);
163  }
164  return $this;
165  }
$config
Definition: fraud_order.php:17
setOption($name, $value)
Definition: Core.php:211
$value
Definition: gender.phtml:16
if(!isset($_GET['name'])) $name
Definition: log.php:14

◆ setLifetime()

setLifetime (   $newLifetime)

Force a new lifetime

The new value is set for the core/frontend but for the backend too (directive)

Parameters
int$newLifetimeNew lifetime (in seconds)
Returns
void

Definition at line 280 of file Core.php.

281  {
282  $this->_options['lifetime'] = $newLifetime;
283  $this->_backend->setDirectives(array(
284  'lifetime' => $newLifetime
285  ));
286  }

◆ setOption()

setOption (   $name,
  $value 
)

Public frontend to set an option

There is an additional validation (relatively to the protected _setOption method)

Parameters
string$nameName of the option
mixed$valueValue of the option
Exceptions
Zend_Cache_Exception
Returns
void

Definition at line 211 of file Core.php.

212  {
213  if (!is_string($name)) {
214  Zend_Cache::throwException("Incorrect option name!");
215  }
216  $name = strtolower($name);
217  if (array_key_exists($name, $this->_options)) {
218  // This is a Core option
219  $this->_setOption($name, $value);
220  return;
221  }
222  if (array_key_exists($name, $this->_specificOptions)) {
223  // This a specic option of this frontend
224  $this->_specificOptions[$name] = $value;
225  return;
226  }
227  }
$value
Definition: gender.phtml:16
static throwException($msg, Exception $e=null)
Definition: Cache.php:205
if(!isset($_GET['name'])) $name
Definition: log.php:14

◆ test()

test (   $id)

Test if a cache is available for the given id

Parameters
string$idCache id
Returns
int|false Last modified time of cache entry if it is available, false otherwise

Definition at line 324 of file Core.php.

325  {
326  if (!$this->_options['caching']) {
327  return false;
328  }
329  $id = $this->_id($id); // cache id may need prefix
330  $this->_validateIdOrTag($id);
331  $this->_lastId = $id;
332 
333  $this->_log("Zend_Cache_Core: test item '{$id}'", 7);
334  return $this->_backend->test($id);
335  }
_log($message, $priority=4)
Definition: Core.php:737
_validateIdOrTag($string)
Definition: Core.php:670
$id
Definition: fieldset.phtml:14

◆ touch()

touch (   $id,
  $extraLifetime 
)

Give (if possible) an extra lifetime to the given cache id

Parameters
string$idcache id
int$extraLifetime
Returns
boolean true if ok

Definition at line 650 of file Core.php.

651  {
652  if (!$this->_extendedBackend) {
653  Zend_Cache::throwException(self::BACKEND_NOT_IMPLEMENTS_EXTENDED_IF);
654  }
655  $id = $this->_id($id); // cache id may need prefix
656 
657  $this->_log("Zend_Cache_Core: touch item '{$id}'", 7);
658  return $this->_backend->touch($id, $extraLifetime);
659  }
_log($message, $priority=4)
Definition: Core.php:737
$id
Definition: fieldset.phtml:14
static throwException($msg, Exception $e=null)
Definition: Cache.php:205

Field Documentation

◆ $_backend

Zend_Cache_Backend_Interface $_backend = null
protected

Backend Object

Definition at line 41 of file Core.php.

◆ $_backendCapabilities

$_backendCapabilities = array()
protected

Definition at line 128 of file Core.php.

◆ $_directivesList

array $_directivesList = array('lifetime', 'logging', 'logger')
staticprotected

Array of options which have to be transfered to backend

Definition at line 100 of file Core.php.

◆ $_extendedBackend

boolean $_extendedBackend = false
protected

True if the backend implements Zend_Cache_Backend_ExtendedInterface

Definition at line 121 of file Core.php.

◆ $_options

$_options
protected
Initial value:
= array(
'write_control' => true,
'caching' => true,
'cache_id_prefix' => null,
'automatic_serialization' => false,
'automatic_cleaning_factor' => 10,
'lifetime' => 3600,
'logging' => false,
'logger' => null,
'ignore_user_abort' => false
)

Definition at line 83 of file Core.php.

◆ $_specificOptions

array $_specificOptions = array()
protected

Not used for the core, just a sort a hint to get a common setOption() method (for the core and for frontends)

Definition at line 107 of file Core.php.

◆ BACKEND_NOT_IMPLEMENTS_EXTENDED_IF

const BACKEND_NOT_IMPLEMENTS_EXTENDED_IF = 'Current backend doesn\'t implement the Zend_Cache_Backend_ExtendedInterface, so this method is not available'

Definition at line 34 of file Core.php.

◆ BACKEND_NOT_SUPPORTS_TAG

const BACKEND_NOT_SUPPORTS_TAG = 'tags are not supported by the current backend'

Messages

Definition at line 33 of file Core.php.


The documentation for this class was generated from the following file: