|
|
Storage adapters are wrappers for real storage resources such as memory and the filesystem, using the well known adapter pattern.
They comes with tons of methods to read, write and modify stored items and to get information about stored items and the storage.
All adapters implements the interface Zend\Cache\Storage\Adapter
and most extend Zend\Cache\Storage\Adapter\AbstractAdapter, which
comes with basic logic.
Configuration is handled by either
Zend\Cache\Storage\Adapter\AdapterOptions, or an adapter-specific
options class if it exists. You may pass the options instance to the class at
instantiation or via the setOptions() method, or alternately
pass an associative array of options in either place (internally, these are then passed
to an options class instance). Alternately, you can pass either the options instance or
associative array to the Zend\Cache\StorageFactory::factory
method.
Note: Many methods throw exceptions
Because many caching methods can throw exceptions, you need to catch them manually or you can use the plug-in
Zend\Cache\Storage\Plugin\ExceptionHandlerto automatically catch them and redirect exceptions into a log file using the option "exception_callback".
Caching adapters can either be created from the provided
Zend\Cache\StorageFactory factory, or by simply
instantiating one of the Zend\Cache\Storage\Adapter\*classes.
To make life easier, the Zend\Cache\StorageFactory
comes with a factory method to create an adapter
and create/add all requested plugins at once.
use Zend\Cache\StorageFactory;
// Via factory:
$cache = StorageFactory::factory(array(
'adapter' => 'apc',
'plugins' => array(
'exception_handler' => array('throw_exceptions' => false),
),
));
// Alternately:
$cache = StorageFactory::adapterFactory('apc');
$plugin = StorageFactory::adapterFactory('exception_handler', array(
'throw_exceptions' => false,
));
$cache->addPlugin($plugin);
// Or manually:
$cache = new Zend\Cache\Storage\Adapter\Apc();
$plugin = new Zend\Cache\Storage\Plugin\ExceptionHandler(array(
'throw_exceptions' => false,
));
$cache->addPlugin($plugin);
Enables or disables ignoring of missing items.
If enabled and a missing item was requested:
getItem, getMetadata: return false
removeItem[s]: return true
incrementItem[s], decrementItem[s]: add a new item with 0 as base
touchItem[s]: add new empty item
If disabled and a missing item was requested:
getItem, getMetadata, incrementItem[s], decrementItem[s], touchItem[s]
Implements a fluent interface.
Returns boolean
Pattern against which to validate cache keys.
Implements a fluent interface.
Returns string
The "namespace" in which cache items will live.
Implements a fluent interface.
Returns string
Pattern against which to validate namespace values.
Implements a fluent interface.
Returns string
Enable/Disable reading data from cache.
Implements a fluent interface.
Returns boolean
Set time to live.
Implements a fluent interface.
Returns float
Enable/Disable writing data to cache.
Implements a fluent interface.
Returns boolean
Set options.
Implements a fluent interface.
Get options
Returns Zend\Cache\Storage\Adapter\AdapterOptions
Get an item.
Returns mixed
Get multiple items.
Returns array
Test if an item exists.
Returns boolean
Test multiple items.
Returns array
Get metadata of an item.
Returns array|boolean
Get multiple metadata
Returns array
Store an item.
Returns boolean
Store multiple items.
Returns boolean
Add an item.
Returns boolean
Add multiple items.
Returns boolean
Replace an item.
Returns boolean
Replace multiple items.
Returns boolean
Set item only if token matches
It uses the token from received from getItem() to check if the item has changed before overwriting it.
Returns boolean
Reset lifetime of an item
Returns boolean
Reset lifetime of multiple items.
Returns boolean
Remove an item.
Returns boolean
Remove multiple items.
Returns boolean
Increment an item.
Returns int|boolean
Increment multiple items.
Returns boolean
Decrement an item.
Returns int|boolean
Decrement multiple items.
Returns boolean
Request multiple items.
Returns boolean
Find items.
Returns boolean
Fetches the next item from result set
Returns array|boolean
Returns all items of result set.
Returns array
Clear items off all namespaces.
Returns boolean
Clear items by namespace.
Returns boolean
Optimize adapter storage.
Returns boolean
Capabilities of this storage
Returns Zend\Cache\Storage\Capabilities
Get storage capacity.
Returns array|boolean
|
|
Copyright © 2005-2011 Zend Technologies Inc (compiled by mikaelkael with ZFDocumentor - GIT c517eb0).

