1 | <?php |
||
16 | class Cache implements \Countable, CacheInterface |
||
17 | { |
||
18 | const FIELD_NAME_VALUE = 'v'; |
||
19 | const FIELD_NAME_EXPIRED = 'e'; |
||
20 | const FIELD_NAME_TAGS = 't'; |
||
21 | |||
22 | private $collection; |
||
23 | |||
24 | public function __construct(Database $database, $collectionName) |
||
39 | |||
40 | /** |
||
41 | * @return Cache |
||
42 | */ |
||
43 | public function init() |
||
48 | |||
49 | /** |
||
50 | * @return Cache |
||
51 | */ |
||
52 | public function clear() |
||
57 | |||
58 | /** |
||
59 | * @param iterable $keys |
||
60 | * @param mixed|null $default |
||
61 | */ |
||
62 | public function getMultiple($keys, $default = null) |
||
66 | |||
67 | /** |
||
68 | * @param iterable $values |
||
69 | * @param null|int|\DateInterval $ttl |
||
70 | */ |
||
71 | public function setMultiple($values, $ttl = null) |
||
75 | |||
76 | /** |
||
77 | * @param iterable $keys |
||
78 | */ |
||
79 | public function deleteMultiple($keys) |
||
83 | |||
84 | /** |
||
85 | * Set with expiration on concrete date |
||
86 | * |
||
87 | * @param int|string $key |
||
88 | * @param mixed $value |
||
89 | * @param int $timestamp |
||
90 | */ |
||
91 | public function setDueDate($key, $value, $timestamp, array $tags = null) |
||
122 | |||
123 | /** |
||
124 | * Set key that never expired |
||
125 | * |
||
126 | * @param int|string $key |
||
127 | * @param mixed $value |
||
128 | * @param array $tags |
||
129 | * |
||
130 | * @return Cache |
||
131 | */ |
||
132 | public function setNeverExpired($key, $value, array $tags = null) |
||
138 | |||
139 | /** |
||
140 | * Set with expiration in seconds |
||
141 | * |
||
142 | * @param int|string $key |
||
143 | * @param mixed $value |
||
144 | * @param int $ttl |
||
145 | * @param array $tags |
||
146 | * |
||
147 | * @return Cache |
||
148 | */ |
||
149 | public function set($key, $value, $ttl = null, array $tags = null) |
||
156 | |||
157 | /** |
||
158 | * Get value by key |
||
159 | * |
||
160 | * @param string $key |
||
161 | * @param mixed $default |
||
162 | * |
||
163 | * @return array|null |
||
164 | */ |
||
165 | public function get($key, $default = null) |
||
184 | |||
185 | public function delete($key) |
||
193 | |||
194 | /** |
||
195 | * Delete documents by tag |
||
196 | */ |
||
197 | public function deleteMatchingTag($tag) |
||
205 | |||
206 | /** |
||
207 | * Delete documents by tag |
||
208 | */ |
||
209 | public function deleteNotMatchingTag($tag) |
||
217 | |||
218 | /** |
||
219 | * Delete documents by tag |
||
220 | * Document deletes if it contains all passed tags |
||
221 | */ |
||
222 | public function deleteMatchingAllTags(array $tags) |
||
230 | |||
231 | /** |
||
232 | * Delete documents by tag |
||
233 | * Document deletes if it not contains all passed tags |
||
234 | */ |
||
235 | public function deleteMatchingNoneOfTags(array $tags) |
||
243 | |||
244 | /** |
||
245 | * Delete documents by tag |
||
246 | * Document deletes if it contains any of passed tags |
||
247 | */ |
||
248 | public function deleteMatchingAnyTag(array $tags) |
||
256 | |||
257 | /** |
||
258 | * Delete documents by tag |
||
259 | * Document deletes if it contains any of passed tags |
||
260 | */ |
||
261 | public function deleteNotMatchingAnyTag(array $tags) |
||
269 | |||
270 | /** |
||
271 | * Get total count of documents in cache |
||
272 | * |
||
273 | * @return int |
||
274 | */ |
||
275 | public function count() |
||
279 | |||
280 | public function has($key) |
||
284 | } |
||
285 |