-
Notifications
You must be signed in to change notification settings - Fork 1
/
CacheInterface.php
96 lines (85 loc) · 3.27 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
<?php
namespace Psr\SimpleCache;
interface CacheInterface
{
const TTL_MINUTE = 60;
const TTL_HOUR = 3600;
const TTL_DAY = 86400;
/**
* Fetched a value from the cache.
*
* @param string $key The unique key of this item in the cache
*
* @return mixed The value of the item from the cache, or null in case of cache miss
*/
public function get($key);
/**
* Persist data in the cache, uniquely referenced by a key with an optional expiration TTL time.
*
* @param string $key The key of the item to store
* @param mixed $value The value of the item to store
* @param null|integer|DateInterval $ttl Optional. The TTL value of this item. If no value is sent and the driver supports TTL
* then the library may set a default value for it or let the driver take care of that.
*
* @return bool True on success and false on failure
*/
public function set($key, $value, $ttl = null);
/**
* Delete an item from the cache by its unique key
*
* @param string $key The unique cache key of the item to delete
*
* @return bool True on success and false on failure
*/
public function delete($key);
/**
* Wipe clean the entire cache's keys
*
* @return bool True on success and false on failure
*/
public function clear();
/**
* Obtain multiple cache items by their unique keys
*
* @param array|Traversable $keys A list of keys that can obtained in a single operation.
*
* @return array An array of key => value pairs. Cache keys that do not exist or are stale will have a value of null.
*/
public function getMultiple($keys);
/**
* Persisting a set of key => value pairs in the cache, with an optional TTL.
*
* @param array|Traversable $items An array of key => value pairs for a multiple-set operation.
* @param null|integer|DateInterval $ttl Optional. The amount of seconds from the current time that the item will exist in the cache for.
* If this is null then the cache backend will fall back to its own default behaviour.
*
* @return bool True on success and false on failure
*/
public function setMultiple($items, $ttl = null);
/**
* Delete multiple cache items in a single operation
*
* @param array|Traversable $keys The array of string-based keys to be deleted
*
* @return bool True on success and false on failure
*/
public function deleteMultiple($keys);
/**
* Increment a value atomically in the cache by its step value, which defaults to 1
*
* @param string $key The cache item key
* @param integer $step The value to increment by, defaulting to 1
*
* @return int|bool The new value on success and false on failure
*/
public function increment($key, $step = 1);
/**
* Decrement a value atomically in the cache by its step value, which defaults to 1
*
* @param string $key The cache item key
* @param integer $step The value to decrement by, defaulting to 1
*
* @return int|bool The new value on success and false on failure
*/
public function decrement($key, $step = 1);
}