|
5 | 5 | interface CacheInterface |
6 | 6 | { |
7 | 7 | /** |
8 | | - * Fetch a value from the cache. |
| 8 | + * Fetches a value from the cache. |
9 | 9 | * |
10 | | - * @param string $key The unique key of this item in the cache |
11 | | - * @param mixed $default Default value to return if the key does not exist |
| 10 | + * @param string $key The unique key of this item in the cache. |
| 11 | + * @param mixed $default Default value to return if the key does not exist. |
12 | 12 | * |
13 | | - * @return mixed The value of the item from the cache, or $default in case of cache miss |
| 13 | + * @return mixed The value of the item from the cache, or $default in case of cache miss. |
| 14 | + * |
| 15 | + * @throws \Psr\SimpleCache\InvalidArgumentException |
| 16 | + * MUST be thrown if the $key string is not a legal value. |
14 | 17 | */ |
15 | 18 | public function get($key, $default = null); |
16 | 19 |
|
17 | 20 | /** |
18 | | - * Persist data in the cache, uniquely referenced by a key with an optional expiration TTL time. |
| 21 | + * Persists data in the cache, uniquely referenced by a key with an optional expiration TTL time. |
19 | 22 | * |
20 | | - * @param string $key The key of the item to store |
21 | | - * @param mixed $value The value of the item to store |
| 23 | + * @param string $key The key of the item to store. |
| 24 | + * @param mixed $value The value of the item to store, must be serializable. |
22 | 25 | * @param null|int|DateInterval $ttl Optional. The TTL value of this item. If no value is sent and |
23 | 26 | * the driver supports TTL then the library may set a default value |
24 | 27 | * for it or let the driver take care of that. |
25 | 28 | * |
26 | | - * @return bool True on success and false on failure |
| 29 | + * @return bool True on success and false on failure. |
| 30 | + * |
| 31 | + * @throws \Psr\SimpleCache\InvalidArgumentException |
| 32 | + * MUST be thrown if the $key string is not a legal value. |
27 | 33 | */ |
28 | 34 | public function set($key, $value, $ttl = null); |
29 | 35 |
|
30 | 36 | /** |
31 | | - * Delete an item from the cache by its unique key |
| 37 | + * Delete an item from the cache by its unique key. |
| 38 | + * |
| 39 | + * @param string $key The unique cache key of the item to delete. |
32 | 40 | * |
33 | | - * @param string $key The unique cache key of the item to delete |
| 41 | + * @return bool True if the item was successfully removed. False if there was an error. |
34 | 42 | * |
35 | | - * @return void |
| 43 | + * @throws \Psr\SimpleCache\InvalidArgumentException |
| 44 | + * MUST be thrown if the $key string is not a legal value. |
36 | 45 | */ |
37 | 46 | public function delete($key); |
38 | 47 |
|
39 | 48 | /** |
40 | | - * Wipe clean the entire cache's keys |
| 49 | + * Wipes clean the entire cache's keys. |
41 | 50 | * |
42 | | - * @return void |
| 51 | + * @return bool True on success and false on failure. |
43 | 52 | */ |
44 | 53 | public function clear(); |
45 | 54 |
|
46 | 55 | /** |
47 | | - * Obtain multiple cache items by their unique keys |
| 56 | + * Obtains multiple cache items by their unique keys. |
48 | 57 | * |
49 | | - * @param array|Traversable $keys A list of keys that can obtained in a single operation. |
| 58 | + * @param array|\Traversable $keys A list of keys that can obtained in a single operation. |
| 59 | + * @param mixed $default Default value to return for keys that do not exist. |
50 | 60 | * |
51 | | - * @return array An array of key => value pairs. Cache keys that do not exist or are stale will have a value of null. |
| 61 | + * @return array|\Traversable A list of key => value pairs. Cache keys that do not exist or are stale will have $default as value. |
| 62 | + * |
| 63 | + * @throws \Psr\SimpleCache\InvalidArgumentException |
| 64 | + * MUST be thrown if $keys is neither an array nor a Traversable, |
| 65 | + * or if any of the $keys are not a legal value. |
52 | 66 | */ |
53 | | - public function getMultiple($keys); |
| 67 | + public function getMultiple($keys, $default = null); |
54 | 68 |
|
55 | 69 | /** |
56 | | - * Persisting a set of key => value pairs in the cache, with an optional TTL. |
| 70 | + * Persists a set of key => value pairs in the cache, with an optional TTL. |
57 | 71 | * |
58 | | - * @param array|Traversable $items An array of key => value pairs for a multiple-set operation. |
59 | | - * @param null|int|DateInterval $ttl Optional. The TTL value of this item. If no value is sent and |
60 | | - * the driver supports TTL then the library may set a default value |
61 | | - * for it or let the driver take care of that. |
| 72 | + * @param array|\Traversable $values A list of key => value pairs for a multiple-set operation. |
| 73 | + * @param null|int|DateInterval $ttl Optional. The TTL value of this item. If no value is sent and |
| 74 | + * the driver supports TTL then the library may set a default value |
| 75 | + * for it or let the driver take care of that. |
| 76 | + * |
| 77 | + * @return bool True on success and false on failure. |
62 | 78 | * |
63 | | - * @return bool True on success and false on failure |
| 79 | + * @throws \Psr\SimpleCache\InvalidArgumentException |
| 80 | + * MUST be thrown if $values is neither an array nor a Traversable, |
| 81 | + * or if any of the $values are not a legal value. |
64 | 82 | */ |
65 | | - public function setMultiple($items, $ttl = null); |
| 83 | + public function setMultiple($values, $ttl = null); |
66 | 84 |
|
67 | 85 | /** |
68 | | - * Delete multiple cache items in a single operation |
| 86 | + * Deletes multiple cache items in a single operation. |
| 87 | + * |
| 88 | + * @param array|\Traversable $keys A list of string-based keys to be deleted. |
69 | 89 | * |
70 | | - * @param array|Traversable $keys The array of string-based keys to be deleted |
| 90 | + * @return bool True if the item was successfully removed. False if there was an error. |
71 | 91 | * |
72 | | - * @return void |
| 92 | + * @throws \Psr\SimpleCache\InvalidArgumentException |
| 93 | + * MUST be thrown if $keys is neither an array nor a Traversable, |
| 94 | + * or if any of the $keys are not a legal value. |
73 | 95 | */ |
74 | 96 | public function deleteMultiple($keys); |
75 | 97 |
|
76 | 98 | /** |
77 | | - * Identify if an item is in the cache. |
| 99 | + * Determines whether an item is present in the cache. |
| 100 | + * |
78 | 101 | * NOTE: It is recommended that has() is only to be used for cache warming type purposes |
79 | 102 | * and not to be used within your live applications operations for get/set, as this method |
80 | 103 | * is subject to a race condition where your has() will return true and immediately after, |
81 | 104 | * another script can remove it making the state of your app out of date. |
82 | 105 | * |
83 | | - * @param string $key The cache item key |
| 106 | + * @param string $key The cache item key. |
84 | 107 | * |
85 | 108 | * @return bool |
| 109 | + * |
| 110 | + * @throws \Psr\SimpleCache\InvalidArgumentException |
| 111 | + * MUST be thrown if the $key string is not a legal value. |
86 | 112 | */ |
87 | 113 | public function has($key); |
88 | 114 | } |
0 commit comments