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
- interface BackdropCacheInterface
Expanded class hierarchy of BackdropCacheInterface
See also
cache()
File
- core/
includes/ cache.inc, line 248 - Functions and interfaces for cache handling.
Members
Name | Modifiers | Type | Description |
---|---|---|---|
BackdropCacheInterface:: |
function | Deletes an item from the cache. | |
BackdropCacheInterface:: |
function | Deletes multiple items from the cache. | |
BackdropCacheInterface:: |
function | Deletes items from the cache using a wildcard prefix. | |
BackdropCacheInterface:: |
function | Flushes all cache items in a bin. | |
BackdropCacheInterface:: |
function | Performs garbage collection on a cache bin. Removing expired items. | |
BackdropCacheInterface:: |
function | Returns data from the persistent cache. | |
BackdropCacheInterface:: |
function | Returns data from the persistent cache when given an array of cache IDs. | |
BackdropCacheInterface:: |
function | Checks if a cache bin is empty. | |
BackdropCacheInterface:: |
function | Stores data in the persistent cache. |