5cf54469e9fdd6e4c576f66df43871c7e3a019db
[yaffs-website] / vendor / drush / drush / src / Cache / CacheInterface.php
1 <?php
2
3 /**
4  * @file
5  * Definition of Drush\Cache\CacheInterface.
6  */
7
8 namespace Drush\Cache;
9
10 /**
11  * Interface for cache implementations.
12  *
13  * All cache implementations have to implement this interface.
14  * JSONCache provides the default implementation, which can be
15  * consulted as an example.
16  *
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:
22  * @code
23  *  $options['cache-class-example'] = 'MyCustomCache;
24  * @endcode
25  *
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.
29  * @code
30  *  $options['cache-default-class'] = 'MyCustomCache;
31  * @endcode
32  *
33  * @see \Drupal\Core\Cache\CacheBackendInterface
34  *
35  * @deprecated
36  */
37 interface CacheInterface
38 {
39
40     /**
41      * Constructor.
42      *
43      * @param $bin
44      *   The cache bin for which the object is created.
45      */
46     public function __construct($bin);
47
48     /**
49      * Return data from the persistent cache.
50      *
51      * @param string $cid
52      *   The cache ID of the data to retrieve.
53      *
54      * @return
55      *   The cache or FALSE on failure.
56      */
57     public function get($cid);
58
59     /**
60      * Return data from the persistent cache when given an array of cache IDs.
61      *
62      * @param array $cids
63      *   An array of cache IDs for the data to retrieve. This is passed by
64      *   reference, and will have the IDs successfully returned from cache
65      *   removed.
66      *
67      * @return
68      *   An array of the items successfully returned from cache indexed by cid.
69      */
70     public function getMultiple(&$cids);
71
72     /**
73      * Store data in the persistent cache.
74      *
75      * @param string $cid
76      *   The cache ID of the data to store.
77      * @param array $data
78      *   The data to store in the cache.
79      * @param $expire
80      *   One of the following values:
81      *   - DRUSH_CACHE_PERMANENT: Indicates that the item should never be removed unless
82      *     explicitly told to using _drush_cache_clear_all() with a cache ID.
83      *   - DRUSH_CACHE_TEMPORARY: Indicates that the item should be removed at the next
84      *     general cache wipe.
85      *   - A Unix timestamp: Indicates that the item should be kept at least until
86      *     the given time, after which it behaves like CACHE_TEMPORARY.
87      */
88     public function set($cid, $data, $expire = DRUSH_CACHE_PERMANENT);
89
90     /**
91      * Expire data from the cache. If called without arguments, expirable
92      * entries will be cleared from all known cache bins.
93      *
94      * @param string $cid
95      *   If set, the cache ID to delete. Otherwise, all cache entries that can
96      *   expire are deleted.
97      * @param bool $wildcard
98      *   If set to TRUE, the $cid is treated as a substring
99      *   to match rather than a complete ID. The match is a right hand
100      *   match. If '*' is given as $cid, the bin $bin will be emptied.
101      */
102     public function clear($cid = null, $wildcard = false);
103
104     /**
105      * Check if a cache bin is empty.
106      *
107      * A cache bin is considered empty if it does not contain any valid data for
108      * any cache ID.
109      *
110      * @return
111      *   TRUE if the cache bin specified is empty.
112      */
113     public function isEmpty();
114 }