Cache/Frontend/Class.php
Zend Framework
LICENSE
This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to [email protected] so we can send you a copy immediately.
- Category
- Zend
- Copyright
- Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
- Package
- Zend_Cache
- Subpackage
- Zend_Cache_Frontend
- Version
- $Id: Class.php 24593 2012-01-05 20:35:02Z matthew $
\Zend_Cache_Frontend_Class
- Parent(s)
- \Zend_Cache_Core
- Copyright
- Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
Constants
BACKEND_NOT_SUPPORTS_TAG
= 'tags are not supported by the current backend'
- Inherited_from
- \Zend_Cache_Core::BACKEND_NOT_SUPPORTS_TAG
BACKEND_NOT_IMPLEMENTS_EXTENDED_IF
= 'Current backend doesn\'t implement the Zend_Cache_Backend_ExtendedInterface, so this method is not available'- Inherited_from
- \Zend_Cache_Core::BACKEND_NOT_IMPLEMENTS_EXTENDED_IF
Properties

\Zend_Cache_Backend_Interface $_backend = null
nullDetails- Type
- \Zend_Cache_Backend_Interface
- Inherited_from
- \Zend_Cache_Core::$$_backend

array $_backendCapabilities = array()Array of capabilities of the backend (only if it implements Zend_Cache_Backend_ExtendedInterface)
Inherited from: \Zend_Cache_Core::$$_backendCapabilitiesarray()Details- Type
- array
- Inherited_from
- \Zend_Cache_Core::$$_backendCapabilities

mixed $_cachedEntity = nullThe cached object or the name of the cached abstract class
nullDetails- Type
- mixed

string $_cachedEntityLabel = ''The class name of the cached object or cached abstract class
Used to differentiate between different classes with the same method calls.
''Details- Type
- string

array $_directivesList = array('lifetime', 'logging', 'logger')Array of options which have to be transfered to backend
Inherited from: \Zend_Cache_Core::$$_directivesListarray('lifetime', 'logging', 'logger')Details- Type
- array
- Inherited_from
- \Zend_Cache_Core::$$_directivesList

boolean $_extendedBackend = falseTrue if the backend implements Zend_Cache_Backend_ExtendedInterface
Inherited from: \Zend_Cache_Core::$$_extendedBackendfalseDetails- Type
- boolean
- Inherited_from
- \Zend_Cache_Core::$$_extendedBackend

string $_lastId = null
nullDetails- Type
- string
- Inherited_from
- \Zend_Cache_Core::$$_lastId

array $_options = 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)
====> (boolean) write_control : - Enable / disable write control (the cache is read just after writing to detect corrupt entries) - Enable write control will lightly slow the cache writing but not the cache reading Write control can detect some corrupt cache files but maybe it's not a perfect control
====> (boolean) caching : - Enable / disable caching (can be very useful for the debug of cached scripts)
=====> (string) cache_id_prefix : - prefix for cache ids (namespace)
====> (boolean) automatic_serialization : - Enable / disable automatic serialization - It can be used to save directly datas which aren't strings (but it's slower)
====> (int) automatic_cleaning_factor : - Disable / Tune the automatic cleaning process - The automatic cleaning process destroy too old (for the given life time) cache files when a new cache file is written : 0 => no automatic cache cleaning 1 => systematic cache cleaning x (integer) > 1 => automatic cleaning randomly 1 times on x cache write
====> (int) lifetime : - Cache lifetime (in seconds) - If null, the cache is valid forever.
====> (boolean) logging : - If set to true, logging is activated (but the system is slower)
====> (boolean) ignore_user_abort - If set to true, the core will set the ignore_user_abort PHP flag inside the save() method to avoid cache corruptions in some cases (default false)
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)Details- Type
- array
- Inherited_from
- \Zend_Cache_Core::$$_options

int $_specificLifetime = falseSpecificLifetime value
false => no specific life time
falseDetails- Type
- int

array $_specificOptions = array('cached_entity' => null, 'cache_by_default' => true, 'cached_methods' => array(), 'non_cached_methods' => array())Available options
<p>available options</p>====> (mixed) cached_entity : - if set to a class name, we will cache an abstract class and will use only static calls - if set to an object, we will cache this object methods
====> (boolean) cache_by_default : - if true, method calls will be cached by default
====> (array) cached_methods : - an array of method names which will be cached (even if cache_by_default = false)
====> (array) non_cached_methods : - an array of method names which won't be cached (even if cache_by_default = true)
array('cached_entity' => null, 'cache_by_default' => true, 'cached_methods' => array(), 'non_cached_methods' => array())Details- Type
- array
Methods

__call(string $name, array $parameters) : mixedMain method : call the specified method or get the result from cache
| Name | Type | Description |
|---|---|---|
| $name | string | Method name |
| $parameters | array | Method parameters |
| Type | Description |
|---|---|
| mixed | Result |

__construct(array $options = array()) : voidConstructor
| Name | Type | Description |
|---|---|---|
| $options | array | Associative array of options |
| Exception | Description |
|---|---|
| \Zend_Cache_Exception |

_id(string $id) : string
Checks 'cache_id_prefix' and returns new id with prefix or simply the id if null
| Name | Type | Description |
|---|---|---|
| $id | string | Cache id |
| Type | Description |
|---|---|
| string | Cache id (with or without prefix) |

_log(string $message, $priority = 4) : void
| Name | Type | Description |
|---|---|---|
| $message | string | |
| $priority |
| Exception | Description |
|---|---|
| \Zend_Cache_Exception |

_loggerSanity() : voidMake sure if we enable logging that the Zend_Log class is available.
Inherited from: \Zend_Cache_Core::_loggerSanity()Create a default log object if none is set.
| Exception | Description |
|---|---|
| \Zend_Cache_Exception |

_makeId( $name, $args) : voidZF-9970
| Name | Type | Description |
|---|---|---|
| $name | ||
| $args |
- Deprecated

_setOption(string $name, mixed $value) : void
| Name | Type | Description |
|---|---|---|
| $name | string | Name of the option |
| $value | mixed | Value of the option |
| Exception | Description |
|---|---|
| \Zend_Cache_Exception |

_validateIdOrTag(string $string) : voidValidate a cache id or a tag (security, reliable filenames, reserved prefixes.
Inherited from: \Zend_Cache_Core::_validateIdOrTag()..)
Throw an exception if a problem is found
| Name | Type | Description |
|---|---|---|
| $string | string | Cache id or tag |
| Exception | Description |
|---|---|
| \Zend_Cache_Exception |

_validateTagsArray(array $tags) : voidValidate a tags array (security, reliable filenames, reserved prefixes.
Inherited from: \Zend_Cache_Core::_validateTagsArray()..)
Throw an exception if a problem is found
| Name | Type | Description |
|---|---|---|
| $tags | array | Array of tags |
| Exception | Description |
|---|---|
| \Zend_Cache_Exception |

clean(string $mode = 'all', array | string $tags = array()) : boolean
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)
| Name | Type | Description |
|---|---|---|
| $mode | string | |
| $tags | array | string |
| Type | Description |
|---|---|
| boolean | True if ok |
| Exception | Description |
|---|---|
| \Zend_Cache_Exception |

getFillingPercentage() : intReturn the filling percentage of the backend storage
Inherited from: \Zend_Cache_Core::getFillingPercentage()| Type | Description |
|---|---|
| int | integer between 0 and 100 |

getIdsMatchingAnyTags(array $tags = array()) : arrayReturn an array of stored cache ids which match any given tags
Inherited from: \Zend_Cache_Core::getIdsMatchingAnyTags()In case of multiple tags, a logical OR is made between tags
| Name | Type | Description |
|---|---|---|
| $tags | array | array of tags |
| Type | Description |
|---|---|
| array | array of matching any cache ids (string) |

getIdsMatchingTags(array $tags = array()) : arrayReturn an array of stored cache ids which match given tags
Inherited from: \Zend_Cache_Core::getIdsMatchingTags()In case of multiple tags, a logical AND is made between tags
| Name | Type | Description |
|---|---|---|
| $tags | array | array of tags |
| Type | Description |
|---|---|
| array | array of matching cache ids (string) |

getIdsNotMatchingTags(array $tags = array()) : arrayReturn an array of stored cache ids which don't match given tags
Inherited from: \Zend_Cache_Core::getIdsNotMatchingTags()In case of multiple tags, a logical OR is made between tags
| Name | Type | Description |
|---|---|---|
| $tags | array | array of tags |
| Type | Description |
|---|---|
| array | array of not matching cache ids (string) |

getMetadatas(string $id) : arrayReturn an array of metadatas for the given cache id
Inherited from: \Zend_Cache_Core::getMetadatas()The array will include these keys : - expire : the expire timestamp - tags : a string array of tags - mtime : timestamp of last modification time
| Name | Type | Description |
|---|---|---|
| $id | string | cache id |
| Type | Description |
|---|---|
| array | array of metadatas (false if the cache id is not found) |

getOption(string $name) : mixed
| Name | Type | Description |
|---|---|---|
| $name | string | Name of the option |
| Type | Description |
|---|---|
| mixed | option value |
| Exception | Description |
|---|---|
| \Zend_Cache_Exception |

load(string $id, boolean $doNotTestCacheValidity = false, boolean $doNotUnserialize = false) : mixed | falseTest if a cache is available for the given id and (if yes) return it (false else)
Inherited from: \Zend_Cache_Core::load()| Name | Type | Description |
|---|---|---|
| $id | string | Cache id |
| $doNotTestCacheValidity | boolean | If set to true, the cache validity won't be tested |
| $doNotUnserialize | boolean | Do not serialize (even if automatic_serialization is true) => for internal use |
| Type | Description |
|---|---|
| mixed | false | Cached datas |

makeId(string $name, array $args = array()) : stringMake a cache id from the method name and parameters
| Name | Type | Description |
|---|---|---|
| $name | string | Method name |
| $args | array | Method parameters |
| Type | Description |
|---|---|
| string | Cache id |

remove(string $id) : boolean
| Name | Type | Description |
|---|---|---|
| $id | string | Cache id to remove |
| Type | Description |
|---|---|
| boolean | True if ok |

save(mixed $data, string $id = null, array $tags = array(), int $specificLifetime = false, int $priority = 8) : boolean
| Name | Type | Description |
|---|---|---|
| $data | mixed | Data to put in cache (can be another type than string if automatic_serialization is on) |
| $id | string | Cache id (if not set, the last cache id will be used) |
| $tags | array | Cache tags |
| $specificLifetime | int | If != false, set a specific lifetime for this cache record (null => infinite lifetime) |
| $priority | int | integer between 0 (very low priority) and 10 (maximum priority) used by some particular backends |
| Type | Description |
|---|---|
| boolean | True if no problem |
| Exception | Description |
|---|---|
| \Zend_Cache_Exception |

setBackend(\Zend_Cache_Backend $backendObject) : void
| Name | Type | Description |
|---|---|---|
| $backendObject | \Zend_Cache_Backend |
| Exception | Description |
|---|---|
| \Zend_Cache_Exception |

setCachedEntity(mixed $cachedEntity) : voidSpecific method to set the cachedEntity
if set to a class name, we will cache an abstract class and will use only static calls if set to an object, we will cache this object methods
| Name | Type | Description |
|---|---|---|
| $cachedEntity | mixed |

setConfig(\Zend_Config $config) : \Zend_Cache_CoreSet options using an instance of type Zend_Config
Inherited from: \Zend_Cache_Core::setConfig()| Name | Type | Description |
|---|---|---|
| $config | \Zend_Config |
| Type | Description |
|---|---|
| \Zend_Cache_Core |

setLifetime(int $newLifetime) : void
The new value is set for the core/frontend but for the backend too (directive)
| Name | Type | Description |
|---|---|---|
| $newLifetime | int | New lifetime (in seconds) |

setOption(string $name, mixed $value) : voidPublic frontend to set an option
Just a wrapper to get a specific behaviour for cached_entity
| Name | Type | Description |
|---|---|---|
| $name | string | Name of the option |
| $value | mixed | Value of the option |
| Exception | Description |
|---|---|
| \Zend_Cache_Exception |

setPriority(int $priority) : voidSet the priority (used by some particular backends)
| Name | Type | Description |
|---|---|---|
| $priority | int | integer between 0 (very low priority) and 10 (maximum priority) |

setSpecificLifetime(int $specificLifetime = false) : voidSet a specific life time
| Name | Type | Description |
|---|---|---|
| $specificLifetime | int |

setTagsArray(array $tags = array()) : voidSet the cache array
| Name | Type | Description |
|---|---|---|
| $tags | array |

test(string $id) : int | false
| Name | Type | Description |
|---|---|---|
| $id | string | Cache id |
| Type | Description |
|---|---|
| int | false | Last modified time of cache entry if it is available, false otherwise |

touch(string $id, int $extraLifetime) : booleanGive (if possible) an extra lifetime to the given cache id
Inherited from: \Zend_Cache_Core::touch()| Name | Type | Description |
|---|---|---|
| $id | string | cache id |
| $extraLifetime | int |
| Type | Description |
|---|---|
| boolean | true if ok |