Defines an interface for cache implementations.

All cache implementations have to implement this interface. BackdropDatabaseCache provides the default implementation, which can be consulted as an example.

To make Backdrop use your implementation for a certain cache bin, you have to set a value in settings.php with the name of the cache bin as its key and the name of your class as its value. For example, if your implementation of BackdropCacheInterface was called MyCustomCache, the following line in settings.php would make Backdrop use it for the 'cache_page' bin:

 $settings['cache_class_cache_page'] = 'MyCustomCache';

Additionally, you can register your cache implementation to be used by default for all cache bins by setting the $settings['cache_default_class'] to the name of your implementation of the BackdropCacheInterface, e.g.

 $settings['cache_default_class'] = 'MyCustomCache';

To implement a completely custom cache bin, use the same format:

 $settings['cache_class_custom_bin'] = 'MyCustomCache';

To access your custom cache bin, specify the name of the bin when storing or retrieving cached data:

 cache('custom_bin')->set($cid, $data, $expire);
 cache('custom_bin')->get($cid, 'custom_bin');

Implemented by

Hierarchy

Expanded class hierarchy of BackdropCacheInterface

See also

cache()

BackdropDatabaseCache

File

core/includes/cache.inc, line 250
Functions and interfaces for cache handling.

Members

Contains filters are case sensitive
Namesort descending Modifiers Type Description
BackdropCacheInterface::delete function Deletes an item from the cache.
BackdropCacheInterface::deleteMultiple function Deletes multiple items from the cache.
BackdropCacheInterface::deletePrefix function Deletes items from the cache using a wildcard prefix.
BackdropCacheInterface::flush function Flushes all cache items in a bin.
BackdropCacheInterface::garbageCollection function Performs garbage collection on a cache bin. Removing expired items.
BackdropCacheInterface::get function Returns data from the persistent cache.
BackdropCacheInterface::getMultiple function Returns data from the persistent cache when given an array of cache IDs.
BackdropCacheInterface::isEmpty function Checks if a cache bin is empty.
BackdropCacheInterface::set function Stores data in the persistent cache.