The ClassCache pattern is an extension to the CallbackCache pattern. It has the same methods but instead it generates the internally used callback in base of the configured class name and the given method name.
Instantiating the class cache pattern
1 2 3 4 5 6 | use Zend\Cache\PatternFactory;
$classCache = PatternFactory::factory('class', array(
'class' => 'MyClass',
'storage' => 'apc'
));
|
Option | Data Type | Default Value | Description |
---|---|---|---|
storage | string array Zend\Cache\Storage\StorageInterface | <none> | The storage to write/read cached data |
class | string | <none> | The class name |
cache_output | boolean | true | Cache output of callback |
cache_by_default | boolean | true | Cache method calls by default |
class_cache_methods | array | [] | List of methods to cache (If cache_by_default is disabled) |
class_non_cache_methods | array | [] | List of methods to no-cache (If cache_by_default is enabled) |
Call the specified method of the configured class.
Return type: | mixed |
---|
Call the specified method of the configured class.
Return type: | mixed |
---|
Set a static property of the configured class.
Return type: | void |
---|
Get a static property of the configured class.
Return type: | mixed |
---|
Checks if a static property of the configured class exists.
Return type: | boolean |
---|
Unset a static property of the configured class.
Return type: | void |
---|
Generate a unique key in base of a key representing the callback part and a key representing the arguments part.
Return type: | string |
---|
Set pattern options.
Return type: | Zend\Cache\Pattern\ClassCache |
---|
Get all pattern options.
Return type: | Zend\Cache\Pattern\PatternOptions |
---|
Caching of import feeds
1 2 3 4 5 6 7 8 9 10 11 12 | $cachedFeedReader = Zend\Cache\PatternFactory::factory('class', array(
'class' => 'Zend\Feed\Reader\Reader',
'storage' => 'apc',
// The feed reader doesn't output anything
// so the output don't need to be caught and cached
'cache_output' => false,
));
$feed = $cachedFeedReader->call("import", array('http://www.planet-php.net/rdf/'));
// OR
$feed = $cachedFeedReader->import('http://www.planet-php.net/rdf/');
|
The source code of this file is hosted on GitHub. Everyone can update and fix errors in this document with few clicks - no downloads needed.