Cache storage plugins are objects to add missing functionality or to influence behavior of a storage adapter.
The plugins listen to events the adapter triggers and can change called method arguments (*.post - events), skipping and directly return a result (using stopPropagation), changing the result (with setResult of Zend\Cache\Storage\PostEvent) and catching exceptions (with Zend\Cache\Storage\ExceptionEvent).
Storage plugins can either be created from Zend\Cache\StorageFactory with the pluginFactory, or by simply instantiating one of the Zend\Cache\Storage\Plugin\*classes.
To make life easier, the Zend\Cache\StorageFactory comes with the method factory to create an adapter and all given plugins at once.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
use Zend\Cache\StorageFactory; // Via factory: $cache = StorageFactory::factory(array( 'adapter' => 'filesystem', 'plugins' => array('serializer'), )); // Alternately: $cache = StorageFactory::adapterFactory('filesystem'); $plugin = StorageFactory::pluginFactory('serializer'); $cache->addPlugin($plugin); // Or manually: $cache = new Zend\Cache\Storage\Adapter\Filesystem(); $plugin = new Zend\Cache\Storage\Plugin\Serializer(); $cache->addPlugin($plugin);
Set the automatic clearing factor. Used by the ClearByFactor plugin.
Flag indicating whether or not to clear by namespace. Used by the ClearByFactor plugin.
Set callback to call on intercepted exception. Used by the ExceptionHandler plugin.
Set automatic optimizing factor. Used by the OptimizeByFactor plugin.
Set serializer adapter to use. Used by Serializer plugin.
Set configuration options for instantiating a serializer adapter. Used by the Serializer plugin.
Set flag indicating we should re-throw exceptions. Used by the ExceptionHandler plugin.
Implements a fluent interface.
Defined by Zend\EventManager\ListenerAggregate, attach one or more listeners.
Defined by Zend\EventManager\ListenerAggregate, detach all previously attached listeners.
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.