1 | <?php |
||
13 | class Files extends AbstractCache |
||
14 | { |
||
15 | /** |
||
16 | * Constructor. |
||
17 | * |
||
18 | * @param array $options Array of options. |
||
19 | */ |
||
20 | 272 | public function __construct(array $options=null) |
|
31 | |||
32 | /** |
||
33 | * Retrieves the cache content for the given key. |
||
34 | * |
||
35 | * @param string $key The cache key to retrieve. |
||
36 | * @return mixed|null Returns the cached data or null. |
||
37 | */ |
||
38 | 153 | public function loadKey($key) |
|
63 | |||
64 | /** |
||
65 | * Retrieves the cache keys for the given tag. |
||
66 | * |
||
67 | * @param string $tag The cache tag to retrieve. |
||
68 | * @return array|null Returns an array of cache keys or null. |
||
69 | */ |
||
70 | 119 | public function loadTag($tag) |
|
96 | |||
97 | /** |
||
98 | * Get the file data. |
||
99 | * If enable, lock file to preserve atomicity |
||
100 | * |
||
101 | * @param string $path The file path |
||
102 | * @param int $line The line to read. If -1 read the whole file |
||
103 | * @return string |
||
104 | */ |
||
105 | 187 | protected function readFile($path, $line = -1) |
|
128 | |||
129 | /** |
||
130 | * Saves data to the cache. |
||
131 | * |
||
132 | * @param mixed $data The data to cache. |
||
133 | * @param string $key The cache id to save. |
||
134 | * @param array $tags The cache tags for this cache entry. |
||
135 | * @param int $ttl The time-to-live in seconds, if set to null the |
||
136 | * cache is valid forever. |
||
137 | * @return boolean Returns True on success or False on failure. |
||
138 | */ |
||
139 | 221 | public function save($data, $key, array $tags = null, $ttl = null) |
|
161 | |||
162 | /** |
||
163 | * Deletes the specified cache record. |
||
164 | * |
||
165 | * @param string $key The cache id to remove. |
||
166 | * @return boolean Returns True on success or False on failure. |
||
167 | */ |
||
168 | 68 | public function delete($key) |
|
178 | |||
179 | /** |
||
180 | * Removes all the cached entries associated with the given tag names. |
||
181 | * |
||
182 | * @param array $tags The array of tags to remove. |
||
183 | * @return boolean Returns True on success or False on failure. |
||
184 | */ |
||
185 | 17 | public function clean(array $tags) |
|
203 | |||
204 | /** |
||
205 | * Flush all the cached entries. |
||
206 | * |
||
207 | * @param boolean $all Wether to flush the whole database, or (preferably) |
||
208 | * the entries prefixed with prefix_key and prefix_tag. |
||
209 | * @return boolean Returns True on success or False on failure. |
||
210 | */ |
||
211 | 272 | public function flush($all = false) |
|
227 | |||
228 | /** |
||
229 | * Returns the time-to-live (in seconds) for the given key. |
||
230 | * |
||
231 | * @param string $key The name of the key. |
||
232 | * @return int|false Returns the number of seconds left, 0 if valid |
||
233 | * forever or False if the key is non-existant. |
||
234 | */ |
||
235 | 34 | public function getTtl($key) |
|
251 | } |