]> git.mxchange.org Git - friendica.git/blob - src/Core/Cache/ICache.php
f57e105cc0ab880737ef238c3d9f55ad689b6858
[friendica.git] / src / Core / Cache / ICache.php
1 <?php
2
3 namespace Friendica\Core\Cache;
4
5 /**
6  * Cache Interface
7  *
8  * @author Hypolite Petovan <hypolite@mrpetovan.com>
9  */
10 interface ICache
11 {
12         const MONTH        = 2592000;
13         const WEEK         = 604800;
14         const DAY          = 86400;
15         const HOUR         = 3600;
16         const HALF_HOUR    = 1800;
17         const QUARTER_HOUR = 900;
18         const FIVE_MINUTES = 300;
19         const MINUTE       = 60;
20         const INFINITE     = 0;
21
22         /**
23          * Lists all cache keys
24          *
25          * @param string prefix optional a prefix to search
26          *
27          * @return array Empty if it isn't supported by the cache driver
28          */
29         public function getAllKeys($prefix = null);
30
31         /**
32          * Fetches cached data according to the key
33          *
34          * @param string $key The key to the cached data
35          *
36          * @return mixed Cached $value or "null" if not found
37          */
38         public function get($key);
39
40         /**
41          * Stores data in the cache identified by the key. The input $value can have multiple formats.
42          *
43          * @param string  $key      The cache key
44          * @param mixed   $value    The value to store
45          * @param integer $ttl      The cache lifespan, must be one of the Cache constants
46          *
47          * @return bool
48          */
49         public function set($key, $value, $ttl = self::FIVE_MINUTES);
50
51         /**
52          * Delete a key from the cache
53          *
54          * @param string $key      The cache key
55          *
56          * @return bool
57          */
58         public function delete($key);
59
60         /**
61          * Remove outdated data from the cache
62          * @param  boolean $outdated just remove outdated values
63          *
64          * @return bool
65          */
66         public function clear($outdated = true);
67 }