Definition at line 28 of file Core.php.
◆ __construct()
__construct |
( |
|
$options = array() | ) |
|
Constructor
- Parameters
-
- Exceptions
-
- Returns
- void
Definition at line 137 of file Core.php.
144 .
" or Zend_Config instance.");
static throwException($msg, Exception $e=null)
if(!isset($_GET['name'])) $name
◆ _id()
Make and return a cache id
Checks 'cache_id_prefix' and returns new id with prefix or simply the id if null
- Parameters
-
- Returns
- string Cache id (with or without prefix)
Definition at line 757 of file Core.php.
759 if ((
$id !==
null) && isset($this->_options[
'cache_id_prefix'])) {
760 return $this->_options[
'cache_id_prefix'] .
$id;
◆ _log()
_log |
( |
|
$message, |
|
|
|
$priority = 4 |
|
) |
| |
|
protected |
Log a message at the WARN (4) priority.
- Parameters
-
- Exceptions
-
- Returns
- void
Definition at line 737 of file Core.php.
739 if (!$this->_options[
'logging']) {
742 if (!(isset($this->_options[
'logger']) || $this->_options[
'logger'] instanceof
Zend_Log)) {
745 $logger = $this->_options[
'logger'];
static throwException($msg, Exception $e=null)
◆ _loggerSanity()
Make sure if we enable logging that the Zend_Log class is available. Create a default log object if none is set.
- Exceptions
-
- Returns
- void
Definition at line 711 of file Core.php.
713 if (!isset($this->_options[
'logging']) || !$this->_options[
'logging']) {
717 if (isset($this->_options[
'logger']) && $this->_options[
'logger'] instanceof
Zend_Log) {
722 #require_once 'Zend/Log.php'; 723 #require_once 'Zend/Log/Writer/Stream.php'; 724 #require_once 'Zend/Log/Filter/Priority.php'; 727 $this->_options[
'logger'] =
$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 | $string | Cache id or tag |
- Exceptions
-
- Returns
- void
Definition at line 670 of file Core.php.
672 if (!is_string($string)) {
675 if (substr($string, 0, 9) ==
'internal-') {
678 if (!preg_match(
'~^[a-zA-Z0-9_]+$~D', $string)) {
static throwException($msg, Exception $e=null)
◆ _validateTagsArray()
_validateTagsArray |
( |
|
$tags | ) |
|
|
protected |
Validate a tags array (security, reliable filenames, reserved prefixes...)
Throw an exception if a problem is found
- Parameters
-
- Exceptions
-
- Returns
- void
Definition at line 692 of file Core.php.
694 if (!is_array($tags)) {
697 foreach($tags as $tag) {
_validateIdOrTag($string)
static throwException($msg, Exception $e=null)
◆ 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
-
- Returns
- boolean True if ok
Definition at line 451 of file Core.php.
453 if (!$this->_options[
'caching']) {
465 return $this->_backend->clean(
$mode, $tags);
const CLEANING_MODE_NOT_MATCHING_TAG
_validateTagsArray($tags)
if($exist=($block->getProductCollection() && $block->getProductCollection() ->getSize())) $mode
static throwException($msg, Exception $e=null)
const CLEANING_MODE_MATCHING_ANY_TAG
const CLEANING_MODE_MATCHING_TAG
◆ getBackend()
◆ getFillingPercentage()
Return the filling percentage of the backend storage
- Returns
- int integer between 0 and 100
Definition at line 615 of file Core.php.
617 if (!$this->_extendedBackend) {
620 return $this->_backend->getFillingPercentage();
static throwException($msg, Exception $e=null)
◆ getIds()
Return an array of stored cache ids
- Returns
- array array of stored cache ids (string)
Definition at line 572 of file Core.php.
574 if (!$this->_extendedBackend) {
578 $ids = $this->_backend->getIds();
581 if (isset($this->_options[
'cache_id_prefix']) && $this->_options[
'cache_id_prefix'] !==
'') {
582 $prefix = & $this->_options[
'cache_id_prefix'];
584 foreach ($ids as &
$id) {
586 $id = substr(
$id, $prefixLen);
static throwException($msg, Exception $e=null)
◆ 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
-
- Returns
- array array of matching any cache ids (string)
Definition at line 542 of file Core.php.
544 if (!$this->_extendedBackend) {
547 if (!($this->_backendCapabilities[
'tags'])) {
551 $ids = $this->_backend->getIdsMatchingAnyTags($tags);
554 if (isset($this->_options[
'cache_id_prefix']) && $this->_options[
'cache_id_prefix'] !==
'') {
555 $prefix = & $this->_options[
'cache_id_prefix'];
557 foreach ($ids as &
$id) {
559 $id = substr(
$id, $prefixLen);
static throwException($msg, Exception $e=null)
◆ 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
-
- Returns
- array array of matching cache ids (string)
Definition at line 476 of file Core.php.
478 if (!$this->_extendedBackend) {
481 if (!($this->_backendCapabilities[
'tags'])) {
485 $ids = $this->_backend->getIdsMatchingTags($tags);
488 if (isset($this->_options[
'cache_id_prefix']) && $this->_options[
'cache_id_prefix'] !==
'') {
489 $prefix = & $this->_options[
'cache_id_prefix'];
491 foreach ($ids as &
$id) {
493 $id = substr(
$id, $prefixLen);
static throwException($msg, Exception $e=null)
◆ 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
-
- Returns
- array array of not matching cache ids (string)
Definition at line 509 of file Core.php.
511 if (!$this->_extendedBackend) {
514 if (!($this->_backendCapabilities[
'tags'])) {
518 $ids = $this->_backend->getIdsNotMatchingTags($tags);
521 if (isset($this->_options[
'cache_id_prefix']) && $this->_options[
'cache_id_prefix'] !==
'') {
522 $prefix = & $this->_options[
'cache_id_prefix'];
524 foreach ($ids as &
$id) {
526 $id = substr(
$id, $prefixLen);
static throwException($msg, Exception $e=null)
◆ getMetadatas()
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
-
- Returns
- array array of metadatas (false if the cache id is not found)
Definition at line 634 of file Core.php.
636 if (!$this->_extendedBackend) {
640 return $this->_backend->getMetadatas(
$id);
static throwException($msg, Exception $e=null)
◆ getOption()
Public frontend to get an option value
- Parameters
-
string | $name | Name of the option |
- Exceptions
-
- Returns
- mixed option value
Definition at line 236 of file Core.php.
240 if (array_key_exists(
$name, $this->_options)) {
242 return $this->_options[
$name];
245 if (array_key_exists(
$name, $this->_specificOptions)) {
247 return $this->_specificOptions[
$name];
static throwException($msg, Exception $e=null)
if(!isset($_GET['name'])) $name
◆ getTags()
Return an array of stored tags
- Returns
- array array of stored tags (string)
Definition at line 599 of file Core.php.
601 if (!$this->_extendedBackend) {
604 if (!($this->_backendCapabilities[
'tags'])) {
607 return $this->_backend->getTags();
static throwException($msg, Exception $e=null)
◆ 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 | $id | Cache id |
boolean | $doNotTestCacheValidity | If set to true, the cache validity won't be tested |
boolean | $doNotUnserialize | Do not serialize (even if automatic_serialization is true) => for internal use |
- Returns
- mixed|false Cached datas
Definition at line 296 of file Core.php.
298 if (!$this->_options[
'caching']) {
302 $this->_lastId =
$id;
305 $this->
_log(
"Zend_Cache_Core: load item '{$id}'", 7);
306 $data = $this->_backend->load(
$id, $doNotTestCacheValidity);
311 if ((!$doNotUnserialize) && $this->_options[
'automatic_serialization']) {
313 return unserialize(
$data);
_log($message, $priority=4)
_validateIdOrTag($string)
◆ remove()
Remove a cache
- Parameters
-
string | $id | Cache id to remove |
- Returns
- boolean True if ok
Definition at line 421 of file Core.php.
423 if (!$this->_options[
'caching']) {
429 $this->
_log(
"Zend_Cache_Core: remove item '{$id}'", 7);
430 return $this->_backend->remove(
$id);
_log($message, $priority=4)
_validateIdOrTag($string)
◆ save()
save |
( |
|
$data, |
|
|
|
$id = null , |
|
|
|
$tags = array() , |
|
|
|
$specificLifetime = false , |
|
|
|
$priority = 8 |
|
) |
| |
Save some data in a cache
- Parameters
-
mixed | $data | Data to put in cache (can be another type than string if automatic_serialization is on) |
string | $id | Cache id (if not set, the last cache id will be used) |
array | $tags | Cache tags |
int | $specificLifetime | If != false, set a specific lifetime for this cache record (null => infinite lifetime) |
int | $priority | integer between 0 (very low priority) and 10 (maximum priority) used by some particular backends |
- Exceptions
-
- Returns
- boolean True if no problem
Definition at line 348 of file Core.php.
350 if (!$this->_options[
'caching']) {
354 $id = $this->_lastId;
360 if ($this->_options[
'automatic_serialization']) {
364 if (!is_string(
$data)) {
370 if ($this->_options[
'automatic_cleaning_factor'] > 0) {
371 $rand = rand(1, $this->_options[
'automatic_cleaning_factor']);
374 if ($this->_extendedBackend || method_exists($this->_backend,
'isAutomaticCleaningAvailable')) {
375 $this->
_log(
"Zend_Cache_Core::save(): automatic cleaning running", 7);
378 $this->
_log(
"Zend_Cache_Core::save(): automatic cleaning is not available/necessary with current backend", 4);
383 $this->
_log(
"Zend_Cache_Core: save item '{$id}'", 7);
384 if ($this->_options[
'ignore_user_abort']) {
385 $abort = ignore_user_abort(
true);
387 if (($this->_extendedBackend) && ($this->_backendCapabilities[
'priority'])) {
388 $result = $this->_backend->save(
$data,
$id, $tags, $specificLifetime, $priority);
392 if ($this->_options[
'ignore_user_abort']) {
393 ignore_user_abort($abort);
398 $this->
_log(
"Zend_Cache_Core::save(): failed to save item '{$id}' -> removing it", 4);
399 $this->_backend->remove(
$id);
403 if ($this->_options[
'write_control']) {
404 $data2 = $this->_backend->load(
$id,
true);
406 $this->
_log(
"Zend_Cache_Core::save(): write control of item '{$id}' failed -> removing it", 4);
407 $this->_backend->remove(
$id);
_log($message, $priority=4)
_validateIdOrTag($string)
_validateTagsArray($tags)
static throwException($msg, Exception $e=null)
clean($mode='all', $tags=array())
◆ setBackend()
Set the backend
- Parameters
-
- Exceptions
-
- Returns
- void
Definition at line 174 of file Core.php.
176 $this->_backend= $backendObject;
179 $directives = array();
181 $directives[$directive] = $this->_options[$directive];
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();
◆ setConfig()
◆ setLifetime()
setLifetime |
( |
|
$newLifetime | ) |
|
Force a new lifetime
The new value is set for the core/frontend but for the backend too (directive)
- Parameters
-
int | $newLifetime | New lifetime (in seconds) |
- Returns
- void
Definition at line 280 of file Core.php.
282 $this->_options[
'lifetime'] = $newLifetime;
283 $this->_backend->setDirectives(array(
284 'lifetime' => $newLifetime
◆ setOption()
setOption |
( |
|
$name, |
|
|
|
$value |
|
) |
| |
Public frontend to set an option
There is an additional validation (relatively to the protected _setOption method)
- Parameters
-
string | $name | Name of the option |
mixed | $value | Value of the option |
- Exceptions
-
- Returns
- void
Definition at line 211 of file Core.php.
213 if (!is_string(
$name)) {
217 if (array_key_exists(
$name, $this->_options)) {
222 if (array_key_exists(
$name, $this->_specificOptions)) {
static throwException($msg, Exception $e=null)
if(!isset($_GET['name'])) $name
◆ test()
Test if a cache is available for the given id
- Parameters
-
- Returns
- int|false Last modified time of cache entry if it is available, false otherwise
Definition at line 324 of file Core.php.
326 if (!$this->_options[
'caching']) {
331 $this->_lastId =
$id;
333 $this->
_log(
"Zend_Cache_Core: test item '{$id}'", 7);
334 return $this->_backend->test(
$id);
_log($message, $priority=4)
_validateIdOrTag($string)
◆ touch()
touch |
( |
|
$id, |
|
|
|
$extraLifetime |
|
) |
| |
Give (if possible) an extra lifetime to the given cache id
- Parameters
-
string | $id | cache id |
int | $extraLifetime | |
- Returns
- boolean true if ok
Definition at line 650 of file Core.php.
652 if (!$this->_extendedBackend) {
657 $this->
_log(
"Zend_Cache_Core: touch item '{$id}'", 7);
658 return $this->_backend->touch(
$id, $extraLifetime);
_log($message, $priority=4)
static throwException($msg, Exception $e=null)
◆ $_backend
Backend Object
Definition at line 41 of file Core.php.
◆ $_backendCapabilities
$_backendCapabilities = array() |
|
protected |
◆ $_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 |
◆ $_options
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
◆ BACKEND_NOT_SUPPORTS_TAG
const BACKEND_NOT_SUPPORTS_TAG = 'tags are not supported by the current backend' |
The documentation for this class was generated from the following file:
- vendor/magento/zendframework1/library/Zend/Cache/Core.php