1 | <?php |
||
9 | final class Cache implements CacheAdapter |
||
10 | { |
||
11 | /** |
||
12 | * @var CacheAdapter |
||
13 | */ |
||
14 | private $cache; |
||
15 | |||
16 | /** |
||
17 | * @var string |
||
18 | */ |
||
19 | private $namespace; |
||
20 | |||
21 | |||
22 | /** |
||
23 | * @param CacheAdapter $cache |
||
24 | * @param string $namespace |
||
25 | * @param int $expires |
||
26 | */ |
||
27 | public function __construct(CacheAdapter $cache = null, $namespace = '', $expires = 0) |
||
36 | |||
37 | /** |
||
38 | * @param $key |
||
39 | * @return mixed |
||
40 | */ |
||
41 | public function get($key) |
||
45 | |||
46 | /** |
||
47 | * @param string $key |
||
48 | * @param int $value |
||
49 | * @param null $ttl |
||
50 | * @return $this |
||
51 | */ |
||
52 | public function set($key, $value, $ttl = null) |
||
57 | |||
58 | /** |
||
59 | * Allows to set a default ttl value if none is provided for set() |
||
60 | * |
||
61 | * @param int $ttl |
||
62 | * |
||
63 | * @return bool|mixed |
||
64 | */ |
||
65 | public function defaultTtl($ttl) |
||
69 | |||
70 | /** |
||
71 | * Delete a value identified by $key. |
||
72 | * |
||
73 | * @param string $key |
||
74 | */ |
||
75 | public function delete($key) |
||
79 | |||
80 | /** |
||
81 | * Checks the availability of the cache service. |
||
82 | * |
||
83 | * @return bool |
||
84 | */ |
||
85 | public function isAvailable() |
||
89 | |||
90 | /** |
||
91 | * Check if value was found in the cache or not. |
||
92 | * |
||
93 | * @return bool |
||
94 | */ |
||
95 | public function isHit() |
||
99 | |||
100 | /** |
||
101 | * Clears all expired values from cache. |
||
102 | * |
||
103 | * @return mixed |
||
104 | */ |
||
105 | public function clear() |
||
109 | |||
110 | /** |
||
111 | * Clears all values from the cache. |
||
112 | * |
||
113 | * @return mixed |
||
114 | */ |
||
115 | public function drop() |
||
119 | } |
||
120 |