Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Attributes
Zend_Cache_Backend_Test Class Reference
Inheritance diagram for Zend_Cache_Backend_Test:
Zend_Cache_Backend Zend_Cache_Backend_ExtendedInterface Zend_Cache_Backend_Interface

Public Member Functions

 __construct ($options=array())
 
 setDirectives ($directives)
 
 load ($id, $doNotTestCacheValidity=false)
 
 test ($id)
 
 save ($data, $id, $tags=array(), $specificLifetime=false)
 
 remove ($id)
 
 clean ($mode=Zend_Cache::CLEANING_MODE_ALL, $tags=array())
 
 getLastLog ()
 
 getLogIndex ()
 
 getAllLogs ()
 
 isAutomaticCleaningAvailable ()
 
 getIds ()
 
 getTags ()
 
 getIdsMatchingTags ($tags=array())
 
 getIdsNotMatchingTags ($tags=array())
 
 getIdsMatchingAnyTags ($tags=array())
 
 getFillingPercentage ()
 
 getMetadatas ($id)
 
 touch ($id, $extraLifetime)
 
 getCapabilities ()
 
- Public Member Functions inherited from Zend_Cache_Backend
 __construct (array $options=array())
 
 setDirectives ($directives)
 
 setOption ($name, $value)
 
 getOption ($name)
 
 getLifetime ($specificLifetime)
 
 isAutomaticCleaningAvailable ()
 
 getTmpDir ()
 

Protected Attributes

 $_options = array()
 
 $_directives = array()
 
- Protected Attributes inherited from Zend_Cache_Backend
 $_directives
 
 $_options = array()
 

Additional Inherited Members

- Protected Member Functions inherited from Zend_Cache_Backend
 _isGoodTmpDir ($dir)
 
 _loggerSanity ()
 
 _log ($message, $priority=4)
 

Detailed Description

Definition at line 40 of file Test.php.

Constructor & Destructor Documentation

◆ __construct()

__construct (   $options = array())

Constructor

Parameters
array$optionsassociative array of options
Returns
void

Definition at line 76 of file Test.php.

77  {
78  $this->_addLog('construct', array($options));
79  }

Member Function Documentation

◆ clean()

clean (   $mode = Zend_Cache::CLEANING_MODE_ALL,
  $tags = array() 
)

Clean some cache records

For this test backend only, if $mode == 'false', then the method will return false (true else)

Available modes are : Zend_Cache::CLEANING_MODE_ALL (default) => remove all cache entries ($tags is not used) Zend_Cache::CLEANING_MODE_OLD => remove too old cache entries ($tags is not used) Zend_Cache::CLEANING_MODE_MATCHING_TAG => remove cache entries matching all given tags ($tags can be an array of strings or a single string) Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG => remove cache entries not {matching one of the given tags} ($tags can be an array of strings or a single string)

Parameters
string$modeClean mode
array$tagsArray of tags
Returns
boolean True if no problem

Implements Zend_Cache_Backend_Interface.

Definition at line 212 of file Test.php.

213  {
214  $this->_addLog('clean', array($mode, $tags));
215  if ($mode=='false') {
216  return false;
217  }
218  return true;
219  }
if($exist=($block->getProductCollection() && $block->getProductCollection() ->getSize())) $mode
Definition: grid.phtml:15

◆ getAllLogs()

getAllLogs ( )

Get the complete log array

Returns
array Complete log array

Definition at line 246 of file Test.php.

247  {
248  return $this->_log;
249  }

◆ getCapabilities()

getCapabilities ( )

Return an associative array of capabilities (booleans) of the backend

The array must include these keys :

  • automatic_cleaning (is automating cleaning necessary)
  • tags (are tags supported)
  • expired_read (is it possible to read expired cache records (for doNotTestCacheValidity option for example))
  • priority does the backend deal with priority when saving
  • infinite_lifetime (is infinite lifetime can work with this backend)
  • get_list (is it possible to get the list of cache ids and the complete list of tags)
Returns
array associative of with capabilities

Implements Zend_Cache_Backend_ExtendedInterface.

Definition at line 388 of file Test.php.

389  {
390  return array(
391  'automatic_cleaning' => true,
392  'tags' => true,
393  'expired_read' => false,
394  'priority' => true,
395  'infinite_lifetime' => true,
396  'get_list' => true
397  );
398  }

◆ getFillingPercentage()

getFillingPercentage ( )

Return the filling percentage of the backend storage

Returns
int integer between 0 and 100

Implements Zend_Cache_Backend_ExtendedInterface.

Definition at line 341 of file Test.php.

342  {
343  return 50;
344  }

◆ getIds()

getIds ( )

Return an array of stored cache ids

Returns
array array of stored cache ids (string)

Implements Zend_Cache_Backend_ExtendedInterface.

Definition at line 266 of file Test.php.

267  {
268  return array(
269  'prefix_id1', 'prefix_id2'
270  );
271  }

◆ getIdsMatchingAnyTags()

getIdsMatchingAnyTags (   $tags = array())

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

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

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

Implements Zend_Cache_Backend_ExtendedInterface.

Definition at line 327 of file Test.php.

328  {
329  if ($tags == array('tag5', 'tag6')) {
330  return array('prefix_id5', 'prefix_id6');
331  }
332 
333  return array();
334  }

◆ 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)

Implements Zend_Cache_Backend_ExtendedInterface.

Definition at line 293 of file Test.php.

294  {
295  if ($tags == array('tag1', 'tag2')) {
296  return array('prefix_id1', 'prefix_id2');
297  }
298 
299  return array();
300  }

◆ 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)

Implements Zend_Cache_Backend_ExtendedInterface.

Definition at line 310 of file Test.php.

311  {
312  if ($tags == array('tag3', 'tag4')) {
313  return array('prefix_id3', 'prefix_id4');
314  }
315 
316  return array();
317  }

◆ getLastLog()

getLastLog ( )

Get the last log

Returns
string The last log

Definition at line 226 of file Test.php.

227  {
228  return $this->_log[$this->_index - 1];
229  }
_log($message, $priority=4)
Definition: Backend.php:273

◆ getLogIndex()

getLogIndex ( )

Get the log index

Returns
int Log index

Definition at line 236 of file Test.php.

237  {
238  return $this->_index;
239  }

◆ getMetadatas()

getMetadatas (   $id)

Return an array of metadatas for the given cache id

The array must 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)

Implements Zend_Cache_Backend_ExtendedInterface.

Definition at line 357 of file Test.php.

358  {
359  return false;
360  }

◆ getTags()

getTags ( )

Return an array of stored tags

Returns
array array of stored tags (string)

Implements Zend_Cache_Backend_ExtendedInterface.

Definition at line 278 of file Test.php.

279  {
280  return array(
281  'tag1', 'tag2'
282  );
283  }

◆ isAutomaticCleaningAvailable()

isAutomaticCleaningAvailable ( )

Return true if the automatic cleaning is available for the backend

Returns
boolean

Definition at line 256 of file Test.php.

257  {
258  return true;
259  }

◆ load()

load (   $id,
  $doNotTestCacheValidity = false 
)

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

For this test backend only, if $id == 'false', then the method will return false if $id == 'serialized', the method will return a serialized array ('foo' else)

Parameters
string$idCache id
boolean$doNotTestCacheValidityIf set to true, the cache validity won't be tested
Returns
string Cached datas (or false)

Implements Zend_Cache_Backend_Interface.

Definition at line 103 of file Test.php.

104  {
105  $this->_addLog('get', array($id, $doNotTestCacheValidity));
106 
107  if ( $id == 'false'
108  || $id == 'd8523b3ee441006261eeffa5c3d3a0a7'
109  || $id == 'e83249ea22178277d5befc2c5e2e9ace'
110  || $id == '40f649b94977c0a6e76902e2a0b43587'
111  || $id == '88161989b73a4cbfd0b701c446115a99'
112  || $id == '205fc79cba24f0f0018eb92c7c8b3ba4'
113  || $id == '170720e35f38150b811f68a937fb042d')
114  {
115  return false;
116  }
117  if ($id=='serialized') {
118  return serialize(array('foo'));
119  }
120  if ($id=='serialized2') {
121  return serialize(array('headers' => array(), 'data' => 'foo'));
122  }
123  if ( $id == '71769f39054f75894288e397df04e445' || $id == '615d222619fb20b527168340cebd0578'
124  || $id == '8a02d218a5165c467e7a5747cc6bd4b6' || $id == '648aca1366211d17cbf48e65dc570bee'
125  || $id == '4a923ef02d7f997ca14d56dfeae25ea7') {
126  return serialize(array('foo', 'bar'));
127  }
128  if ( $id == 'f53c7d912cc523d9a65834c8286eceb9') {
129  return serialize(array('foobar'));
130  }
131  return 'foo';
132  }
$id
Definition: fieldset.phtml:14

◆ remove()

remove (   $id)

Remove a cache record

For this test backend only, if $id == 'false', then the method will return false (true else)

Parameters
string$idCache id
Returns
boolean True if no problem

Implements Zend_Cache_Backend_Interface.

Definition at line 185 of file Test.php.

186  {
187  $this->_addLog('remove', array($id));
188  if (substr($id,-5)=='false') {
189  return false;
190  }
191  return true;
192  }
$id
Definition: fieldset.phtml:14

◆ save()

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

Save some string datas into a cache record

For this test backend only, if $id == 'false', then the method will return false (true else)

Parameters
string$dataDatas to cache
string$idCache id
array$tagsArray of strings, the cache record will be tagged by each string entry
int$specificLifetimeIf != false, set a specific lifetime for this cache record (null => infinite lifetime)
Returns
boolean True if no problem

Implements Zend_Cache_Backend_Interface.

Definition at line 167 of file Test.php.

168  {
169  $this->_addLog('save', array($data, $id, $tags));
170  if (substr($id,-5)=='false') {
171  return false;
172  }
173  return true;
174  }
$id
Definition: fieldset.phtml:14

◆ setDirectives()

setDirectives (   $directives)

Set the frontend directives

Parameters
array$directivesassoc of directives
Returns
void

Implements Zend_Cache_Backend_Interface.

Definition at line 87 of file Test.php.

88  {
89  $this->_addLog('setDirectives', array($directives));
90  }

◆ test()

test (   $id)

Test if a cache is available or not (for the given id)

For this test backend only, if $id == 'false', then the method will return false (123456 else)

Parameters
string$idCache id
Returns
mixed|false false (a cache is not available) or "last modified" timestamp (int) of the available cache record

Implements Zend_Cache_Backend_Interface.

Definition at line 143 of file Test.php.

144  {
145  $this->_addLog('test', array($id));
146  if ($id=='false') {
147  return false;
148  }
149  if (($id=='3c439c922209e2cb0b54d6deffccd75a')) {
150  return false;
151  }
152  return 123456;
153  }
$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

Implements Zend_Cache_Backend_ExtendedInterface.

Definition at line 369 of file Test.php.

370  {
371  return true;
372  }

Field Documentation

◆ $_directives

$_directives = array()
protected

Definition at line 54 of file Test.php.

◆ $_options

$_options = array()
protected

Definition at line 47 of file Test.php.


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