1 | <?php |
||
20 | class FileStorage extends AbstractStorage |
||
21 | { |
||
22 | /** |
||
23 | * @var string |
||
24 | */ |
||
25 | private $fs; |
||
26 | |||
27 | private $ext; |
||
28 | |||
29 | /** |
||
30 | * File Storage constructor. |
||
31 | * |
||
32 | * @param string $file |
||
33 | * @param DateInterval $ttl |
||
34 | * @throws \Exception |
||
35 | */ |
||
36 | 7 | public function __construct(string $file, DateInterval $ttl) |
|
47 | |||
48 | /** |
||
49 | * Persists data in the cache, uniquely referenced by a key with an optional expiration TTL time. |
||
50 | * |
||
51 | * @param string $key The key of the item to store. |
||
52 | * @param mixed $value The value of the item to store, must be serializable. |
||
53 | * @param null|int $ttl Optional. The TTL value of this item. If no value is sent and |
||
54 | * the driver supports TTL then the library may set a default value |
||
55 | * for it or let the driver take care of that. |
||
56 | * |
||
57 | * @return bool True on success and false on failure. |
||
58 | */ |
||
59 | 4 | public function set($key, $value, $ttl = null) |
|
73 | |||
74 | 4 | private function _createCacheItem(string $key, $value, int $ttl){ |
|
83 | |||
84 | /** |
||
85 | * Determines whether an item is present in the cache. |
||
86 | * |
||
87 | * NOTE: It is recommended that has() is only to be used for cache warming type purposes |
||
88 | * and not to be used within your live applications operations for get/set, as this method |
||
89 | * is subject to a race condition where your has() will return true and immediately after, |
||
90 | * another script can remove it making the state of your app out of date. |
||
91 | * |
||
92 | * @param string $key The cache item key. |
||
93 | * |
||
94 | * @return bool |
||
95 | */ |
||
96 | 4 | public function has($key){ |
|
116 | |||
117 | /** |
||
118 | * Fetches a value from the cache. |
||
119 | * |
||
120 | * @param string $key The unique key of this item in the cache. |
||
121 | * |
||
122 | * @return mixed The value of the item from the cache, or $default in case of cache miss. |
||
123 | * |
||
124 | */ |
||
125 | 1 | public function get($key){ |
|
138 | |||
139 | |||
140 | |||
141 | /** |
||
142 | * Delete an item from the cache by its unique key. |
||
143 | * |
||
144 | * @param string $key The unique cache key of the item to delete. |
||
145 | * |
||
146 | * @return bool True if the item was successfully removed. False if there was an error. |
||
147 | */ |
||
148 | public function delete($key) |
||
152 | |||
153 | /** |
||
154 | * Wipes clean the entire cache's keys. |
||
155 | * |
||
156 | * @return bool True on success and false on failure. |
||
157 | */ |
||
158 | 1 | public function clear(){ |
|
171 | } |
||
172 |