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