1 | <?php |
||
8 | class ArrayCacheEngine extends BaseCacheEngine |
||
9 | { |
||
10 | |||
11 | protected $cache = array(); |
||
12 | |||
13 | protected $logger = null; |
||
14 | |||
15 | public function __construct($logger = null) |
||
22 | |||
23 | /** |
||
24 | * Determines whether an item is present in the cache. |
||
25 | * NOTE: It is recommended that has() is only to be used for cache warming type purposes |
||
26 | * and not to be used within your live applications operations for get/set, as this method |
||
27 | * is subject to a race condition where your has() will return true and immediately after, |
||
28 | * another script can remove it making the state of your app out of date. |
||
29 | * |
||
30 | * @param string $key The cache item key. |
||
31 | * @return bool |
||
32 | * @throws \Psr\SimpleCache\InvalidArgumentException |
||
33 | * MUST be thrown if the $key string is not a legal value. |
||
34 | */ |
||
35 | public function has($key) |
||
48 | |||
49 | /** |
||
50 | * @param string $key The object KEY |
||
51 | * @param mixed $default IGNORED IN MEMCACHED. |
||
52 | * @return mixed Description |
||
53 | */ |
||
54 | public function get($key, $default = null) |
||
64 | |||
65 | /** |
||
66 | * Persists data in the cache, uniquely referenced by a key with an optional expiration TTL time. |
||
67 | * |
||
68 | * @param string $key The key of the item to store. |
||
69 | * @param mixed $value The value of the item to store, must be serializable. |
||
70 | * @param null|int|DateInterval $ttl Optional. The TTL value of this item. If no value is sent and |
||
71 | * the driver supports TTL then the library may set a default value |
||
72 | * for it or let the driver take care of that. |
||
73 | * |
||
74 | * @return bool True on success and false on failure. |
||
75 | * |
||
76 | * @throws \Psr\SimpleCache\InvalidArgumentException |
||
77 | * MUST be thrown if the $key string is not a legal value. |
||
78 | */ |
||
79 | public function set($key, $value, $ttl = null) |
||
90 | |||
91 | public function clear() |
||
95 | |||
96 | /** |
||
97 | * Unlock resource |
||
98 | * |
||
99 | * @param string $key |
||
100 | * @return bool|void |
||
101 | */ |
||
102 | public function delete($key) |
||
108 | |||
109 | public function isAvailable() |
||
113 | } |
||
114 |