5 * Definition of Drush\Cache\CacheInterface.
11 * Interface for cache implementations.
13 * All cache implementations have to implement this interface.
14 * JSONCache provides the default implementation, which can be
15 * consulted as an example.
17 * To make Drush use your implementation for a certain cache bin, you have to
18 * set a variable with the name of the cache bin as its key and the name of
19 * your class as its value. For example, if your implementation of
20 * CacheInterface was called MyCustomCache, the following line in
21 * drushrc.php would make Drush use it for the 'example' bin:
23 * $options['cache-class-example'] = 'MyCustomCache;
26 * Additionally, you can register your cache implementation to be used by
27 * default for all cache bins by setting the option 'cache-default-class' to
28 * the name of your implementation of the CacheInterface, e.g.
30 * $options['cache-default-class'] = 'MyCustomCache;
33 * @see _drush_cache_get_object()
34 * @see \Drupal\Core\Cache\CacheBackendInterface
36 interface CacheInterface {
42 * The cache bin for which the object is created.
44 function __construct($bin);
47 * Return data from the persistent cache.
50 * The cache ID of the data to retrieve.
53 * The cache or FALSE on failure.
58 * Return data from the persistent cache when given an array of cache IDs.
61 * An array of cache IDs for the data to retrieve. This is passed by
62 * reference, and will have the IDs successfully returned from cache
66 * An array of the items successfully returned from cache indexed by cid.
68 function getMultiple(&$cids);
71 * Store data in the persistent cache.
74 * The cache ID of the data to store.
76 * The data to store in the cache.
78 * One of the following values:
79 * - DRUSH_CACHE_PERMANENT: Indicates that the item should never be removed unless
80 * explicitly told to using _drush_cache_clear_all() with a cache ID.
81 * - DRUSH_CACHE_TEMPORARY: Indicates that the item should be removed at the next
83 * - A Unix timestamp: Indicates that the item should be kept at least until
84 * the given time, after which it behaves like CACHE_TEMPORARY.
86 function set($cid, $data, $expire = DRUSH_CACHE_PERMANENT);
89 * Expire data from the cache. If called without arguments, expirable
90 * entries will be cleared from all known cache bins.
93 * If set, the cache ID to delete. Otherwise, all cache entries that can
95 * @param bool $wildcard
96 * If set to TRUE, the $cid is treated as a substring
97 * to match rather than a complete ID. The match is a right hand
98 * match. If '*' is given as $cid, the bin $bin will be emptied.
100 function clear($cid = NULL, $wildcard = FALSE);
103 * Check if a cache bin is empty.
105 * A cache bin is considered empty if it does not contain any valid data for
109 * TRUE if the cache bin specified is empty.