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

Public Member Functions

 __construct (array $options=array())
 
 load ($id, $doNotTestCacheValidity=false)
 
 test ($id)
 
 save ($data, $id, $tags=array(), $specificLifetime=false)
 
 remove ($id)
 
 clean ($mode=Zend_Cache::CLEANING_MODE_ALL, $tags=array())
 
 isAutomaticCleaningAvailable ()
 
 getFillingPercentage ()
 
 getTags ()
 
 getIdsMatchingTags ($tags=array())
 
 getIdsNotMatchingTags ($tags=array())
 
 getIdsMatchingAnyTags ($tags=array())
 
 getIds ()
 
 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 ()
 
- Public Member Functions inherited from Zend_Cache_Backend_Interface
 setDirectives ($directives)
 

Data Fields

const TAGS_UNSUPPORTED_BY_CLEAN_OF_WINCACHE_BACKEND = 'Zend_Cache_Backend_WinCache::clean() : tags are unsupported by the WinCache backend'
 
const TAGS_UNSUPPORTED_BY_SAVE_OF_WINCACHE_BACKEND = 'Zend_Cache_Backend_WinCache::save() : tags are unsupported by the WinCache backend'
 

Additional Inherited Members

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

Detailed Description

Definition at line 41 of file WinCache.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( array  $options = array())

Constructor

Parameters
array$optionsassociative array of options
Exceptions
Zend_Cache_Exception
Returns
void

Definition at line 56 of file WinCache.php.

57  {
58  if (!extension_loaded('wincache')) {
59  Zend_Cache::throwException('The wincache extension must be loaded for using this backend !');
60  }
61  parent::__construct($options);
62  }
static throwException($msg, Exception $e=null)
Definition: Cache.php:205

Member Function Documentation

◆ clean()

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

Clean some cache records

Available modes are : 'all' (default) => remove all cache entries ($tags is not used) 'old' => unsupported 'matchingTag' => unsupported 'notMatchingTag' => unsupported 'matchingAnyTag' => unsupported

Parameters
string$modeclean mode
array$tagsarray of tags
Exceptions
Zend_Cache_Exception
Returns
boolean true if no problem

Implements Zend_Cache_Backend_Interface.

Definition at line 145 of file WinCache.php.

146  {
147  switch ($mode) {
149  return wincache_ucache_clear();
150  break;
152  $this->_log("Zend_Cache_Backend_WinCache::clean() : CLEANING_MODE_OLD is unsupported by the WinCache backend");
153  break;
157  $this->_log(self::TAGS_UNSUPPORTED_BY_CLEAN_OF_WINCACHE_BACKEND);
158  break;
159  default:
160  Zend_Cache::throwException('Invalid mode for clean() method');
161  break;
162  }
163  }
const CLEANING_MODE_OLD
Definition: Cache.php:73
_log($message, $priority=4)
Definition: Backend.php:273
const CLEANING_MODE_NOT_MATCHING_TAG
Definition: Cache.php:75
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

◆ 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 337 of file WinCache.php.

338  {
339  return array(
340  'automatic_cleaning' => false,
341  'tags' => false,
342  'expired_read' => false,
343  'priority' => false,
344  'infinite_lifetime' => false,
345  'get_list' => true
346  );
347  }

◆ getFillingPercentage()

getFillingPercentage ( )

Return the filling percentage of the backend storage

Exceptions
Zend_Cache_Exception
Returns
int integer between 0 and 100

Implements Zend_Cache_Backend_ExtendedInterface.

Definition at line 184 of file WinCache.php.

185  {
186  $mem = wincache_ucache_meminfo();
187  $memSize = $mem['memory_total'];
188  $memUsed = $memSize - $mem['memory_free'];
189  if ($memSize == 0) {
190  Zend_Cache::throwException('can\'t get WinCache memory size');
191  }
192  if ($memUsed > $memSize) {
193  return 100;
194  }
195  return ((int) (100. * ($memUsed / $memSize)));
196  }
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)

Implements Zend_Cache_Backend_ExtendedInterface.

Definition at line 256 of file WinCache.php.

257  {
258  $res = array();
259  $array = wincache_ucache_info();
260  $records = $array['ucache_entries'];
261  foreach ($records as $record) {
262  $res[] = $record['key_name'];
263  }
264  return $res;
265  }

◆ 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 245 of file WinCache.php.

246  {
247  $this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_WINCACHE_BACKEND);
248  return array();
249  }
_log($message, $priority=4)
Definition: Backend.php:273

◆ 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 217 of file WinCache.php.

218  {
219  $this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_WINCACHE_BACKEND);
220  return array();
221  }
_log($message, $priority=4)
Definition: Backend.php:273

◆ 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 231 of file WinCache.php.

232  {
233  $this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_WINCACHE_BACKEND);
234  return array();
235  }
_log($message, $priority=4)
Definition: Backend.php:273

◆ 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 278 of file WinCache.php.

279  {
280  $tmp = wincache_ucache_get($id);
281  if (is_array($tmp)) {
282  $data = $tmp[0];
283  $mtime = $tmp[1];
284  if (!isset($tmp[2])) {
285  return false;
286  }
287  $lifetime = $tmp[2];
288  return array(
289  'expire' => $mtime + $lifetime,
290  'tags' => array(),
291  'mtime' => $mtime
292  );
293  }
294  return false;
295  }
$id
Definition: fieldset.phtml:14

◆ getTags()

getTags ( )

Return an array of stored tags

Returns
array array of stored tags (string)

Implements Zend_Cache_Backend_ExtendedInterface.

Definition at line 203 of file WinCache.php.

204  {
205  $this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_WINCACHE_BACKEND);
206  return array();
207  }
_log($message, $priority=4)
Definition: Backend.php:273

◆ isAutomaticCleaningAvailable()

isAutomaticCleaningAvailable ( )

Return true if the automatic cleaning is available for the backend

DEPRECATED : use getCapabilities() instead

Deprecated:
Returns
boolean

Definition at line 173 of file WinCache.php.

174  {
175  return false;
176  }

◆ load()

load (   $id,
  $doNotTestCacheValidity = false 
)

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

WARNING $doNotTestCacheValidity=true is unsupported by the WinCache backend

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 73 of file WinCache.php.

74  {
75  $tmp = wincache_ucache_get($id);
76  if (is_array($tmp)) {
77  return $tmp[0];
78  }
79  return false;
80  }
$id
Definition: fieldset.phtml:14

◆ remove()

remove (   $id)

Remove a cache record

Parameters
string$idcache id
Returns
boolean true if no problem

Implements Zend_Cache_Backend_Interface.

Definition at line 125 of file WinCache.php.

126  {
127  return wincache_ucache_delete($id);
128  }
$id
Definition: fieldset.phtml:14

◆ save()

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

Save some string datas into a cache record

Note : $data is always "string" (serialization is done by the core not by the backend)

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 109 of file WinCache.php.

110  {
111  $lifetime = $this->getLifetime($specificLifetime);
112  $result = wincache_ucache_set($id, array($data, time(), $lifetime), $lifetime);
113  if (count($tags) > 0) {
114  $this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_WINCACHE_BACKEND);
115  }
116  return $result;
117  }
$id
Definition: fieldset.phtml:14
_log($message, $priority=4)
Definition: Backend.php:273
getLifetime($specificLifetime)
Definition: Backend.php:143

◆ test()

test (   $id)

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

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

Implements Zend_Cache_Backend_Interface.

Definition at line 88 of file WinCache.php.

89  {
90  $tmp = wincache_ucache_get($id);
91  if (is_array($tmp)) {
92  return $tmp[1];
93  }
94  return false;
95  }
$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 304 of file WinCache.php.

305  {
306  $tmp = wincache_ucache_get($id);
307  if (is_array($tmp)) {
308  $data = $tmp[0];
309  $mtime = $tmp[1];
310  if (!isset($tmp[2])) {
311  return false;
312  }
313  $lifetime = $tmp[2];
314  $newLifetime = $lifetime - (time() - $mtime) + $extraLifetime;
315  if ($newLifetime <=0) {
316  return false;
317  }
318  return wincache_ucache_set($id, array($data, time(), $newLifetime), $newLifetime);
319  }
320  return false;
321  }
$id
Definition: fieldset.phtml:14

Field Documentation

◆ TAGS_UNSUPPORTED_BY_CLEAN_OF_WINCACHE_BACKEND

const TAGS_UNSUPPORTED_BY_CLEAN_OF_WINCACHE_BACKEND = 'Zend_Cache_Backend_WinCache::clean() : tags are unsupported by the WinCache backend'

Log message

Definition at line 46 of file WinCache.php.

◆ TAGS_UNSUPPORTED_BY_SAVE_OF_WINCACHE_BACKEND

const TAGS_UNSUPPORTED_BY_SAVE_OF_WINCACHE_BACKEND = 'Zend_Cache_Backend_WinCache::save() : tags are unsupported by the WinCache backend'

Definition at line 47 of file WinCache.php.


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