The callback cache pattern caches calls of non specific functions and methods given as a callback.
For instantiation you can use the PatternFactory or do it manual:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | use Zend\Cache\PatternFactory;
use Zend\Cache\Pattern\PatternOptions;
// Via the factory:
$callbackCache = PatternFactory::factory('callback', array(
'storage' => 'apc',
'cache_output' => true,
));
// OR, the equivalent manual instantiation:
$callbackCache = new \Zend\Cache\Pattern\CallbackCache();
$callbackCache->setOptions(new PatternOptions(array(
'storage' => 'apc',
'cache_output' => true,
)));
|
Option | Data Type | Default Value | Description |
---|---|---|---|
storage | string array Zend\Cache\Storage\StorageInterface | <none> | The storage to write/read cached data |
cache_output | boolean | true | Cache output of callback |
Call the specified callback or get the result from cache.
Return type: | mixed |
---|
Function call handler.
Return type: | mixed |
---|
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\CallbackCache |
---|
Get all pattern options.
Return type: | Zend\Cache\Pattern\PatternOptions |
---|
Instantiating the callback cache pattern
1 2 3 4 5 | use Zend\Cache\PatternFactory;
$callbackCache = PatternFactory::factory('callback', array(
'storage' => 'apc'
));
|
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.