1 | <?php |
||
25 | class SimpleCacheAdapter extends Component implements CacheInterface |
||
26 | { |
||
27 | /** |
||
28 | * @var YiiCacheInterface |
||
29 | */ |
||
30 | public $cache; |
||
31 | |||
32 | /** |
||
33 | * @throws \yii\base\InvalidConfigException |
||
34 | */ |
||
35 | public function init() |
||
50 | |||
51 | /** |
||
52 | * @return YiiCacheInterface |
||
53 | */ |
||
54 | protected function getCache(): YiiCacheInterface |
||
58 | |||
59 | /** |
||
60 | * Cache::get() return false if the value is not in the cache or expired, but PSR-16 return $default(null) |
||
61 | * |
||
62 | * @param string $key |
||
63 | * @param null $default |
||
64 | * @return bool|mixed|null |
||
65 | * @throws InvalidArgumentException |
||
66 | */ |
||
67 | public function get($key, $default = null) |
||
83 | |||
84 | /** |
||
85 | * @param string $key |
||
86 | * @param mixed $value |
||
87 | * @param null $ttl |
||
88 | * @param null $dependency |
||
89 | * @return bool |
||
90 | * @throws InvalidArgumentException |
||
91 | */ |
||
92 | public function set($key, $value, $ttl = null, $dependency = null) |
||
100 | |||
101 | /** |
||
102 | * @param string $key |
||
103 | * @return bool |
||
104 | */ |
||
105 | public function delete($key) |
||
110 | |||
111 | /** |
||
112 | * @return bool |
||
113 | */ |
||
114 | public function clear() |
||
118 | |||
119 | /** |
||
120 | * @param iterable $keys |
||
121 | * @param null $default |
||
122 | * @return array|iterable |
||
123 | */ |
||
124 | public function getMultiple($keys, $default = null) |
||
137 | |||
138 | /** |
||
139 | * @param iterable $values |
||
140 | * @param null $ttl |
||
141 | * @return bool |
||
142 | */ |
||
143 | public function setMultiple($values, $ttl = null) |
||
161 | |||
162 | /** |
||
163 | * @param iterable $keys |
||
164 | * @return bool |
||
165 | */ |
||
166 | public function deleteMultiple($keys) |
||
183 | |||
184 | /** |
||
185 | * @param string $key |
||
186 | * @return bool |
||
187 | */ |
||
188 | public function has($key) |
||
193 | |||
194 | /** |
||
195 | * @param $ttl |
||
196 | * @return null|int |
||
197 | */ |
||
198 | protected function dateIntervalToSeconds($ttl) |
||
210 | |||
211 | |||
212 | /** |
||
213 | * Builds a normalized cache key from a given key. |
||
214 | * |
||
215 | * If the given key is a string containing alphanumeric characters only and no more than 32 characters, |
||
216 | * then the key will be returned back as it is. Otherwise, a normalized key is generated by serializing |
||
217 | * the given key and applying MD5 hashing. |
||
218 | * |
||
219 | * @param mixed $key the key to be normalized |
||
220 | * @return string the generated cache key |
||
221 | */ |
||
222 | protected function buildKey($key) |
||
229 | } |
||
230 |