Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
bc77d7c0 | 4 | | Copyright CiviCRM LLC. All rights reserved. | |
6a488035 | 5 | | | |
bc77d7c0 TO |
6 | | This work is published under the GNU AGPLv3 license with some | |
7 | | permitted exceptions and without any warranty. For full license | | |
8 | | and copyright information, see https://civicrm.org/licensing | | |
6a488035 | 9 | +--------------------------------------------------------------------+ |
d25dd0ee | 10 | */ |
6a488035 TO |
11 | |
12 | /** | |
13 | * | |
14 | * @package CRM | |
ca5cec67 | 15 | * @copyright CiviCRM LLC https://civicrm.org/licensing |
ebf0eb53 TO |
16 | * CRM_Utils_Cache_Interface is a long-standing interface used within CiviCRM |
17 | * for interacting with a cache service. In style and substance, it is extremely | |
18 | * similar to PHP-FIG's SimpleCache interface (PSR-16). Consequently, beginning | |
19 | * with CiviCRM v5.4, this extends \Psr\SimpleCache\CacheInterface. | |
7b5937fe | 20 | * |
ebf0eb53 | 21 | * @see https://www.php-fig.org/psr/psr-16/ |
6a488035 | 22 | */ |
ebf0eb53 | 23 | interface CRM_Utils_Cache_Interface extends \Psr\SimpleCache\CacheInterface { |
6a488035 TO |
24 | |
25 | /** | |
fe482240 | 26 | * Set the value in the cache. |
6a488035 TO |
27 | * |
28 | * @param string $key | |
29 | * @param mixed $value | |
858451a9 TO |
30 | * @param null|int|\DateInterval $ttl |
31 | * @return bool | |
6a488035 | 32 | */ |
858451a9 | 33 | public function set($key, $value, $ttl = NULL); |
6a488035 TO |
34 | |
35 | /** | |
fe482240 | 36 | * Get a value from the cache. |
6a488035 TO |
37 | * |
38 | * @param string $key | |
2da67cc5 | 39 | * @param mixed $default |
72b3a70c | 40 | * @return mixed |
2da67cc5 | 41 | * The previously set value value, or $default (NULL). |
6a488035 | 42 | */ |
2da67cc5 | 43 | public function get($key, $default = NULL); |
6a488035 TO |
44 | |
45 | /** | |
fe482240 | 46 | * Delete a value from the cache. |
6a488035 TO |
47 | * |
48 | * @param string $key | |
eec321a4 | 49 | * @return bool |
6a488035 | 50 | */ |
00be9182 | 51 | public function delete($key); |
6a488035 TO |
52 | |
53 | /** | |
fe482240 | 54 | * Delete all values from the cache. |
124e5288 | 55 | * |
c31de879 TO |
56 | * NOTE: flush() and clear() should be aliases. flush() is specified by |
57 | * Civi's traditional interface, and clear() is specified by PSR-16. | |
58 | * | |
124e5288 | 59 | * @return bool |
c31de879 TO |
60 | * @see clear |
61 | * @deprecated | |
6a488035 | 62 | */ |
00be9182 | 63 | public function flush(); |
96025800 | 64 | |
c31de879 TO |
65 | /** |
66 | * Delete all values from the cache. | |
67 | * | |
68 | * NOTE: flush() and clear() should be aliases. flush() is specified by | |
69 | * Civi's traditional interface, and clear() is specified by PSR-16. | |
70 | * | |
71 | * @return bool | |
72 | * @see flush | |
73 | */ | |
74 | public function clear(); | |
75 | ||
9f70b0e4 TO |
76 | /** |
77 | * Determines whether an item is present in the cache. | |
78 | * | |
79 | * NOTE: It is recommended that has() is only to be used for cache warming type purposes | |
80 | * and not to be used within your live applications operations for get/set, as this method | |
81 | * is subject to a race condition where your has() will return true and immediately after, | |
82 | * another script can remove it making the state of your app out of date. | |
83 | * | |
84 | * @param string $key The cache item key. | |
85 | * | |
86 | * @return bool | |
87 | */ | |
88 | public function has($key); | |
89 | ||
6a488035 | 90 | } |