1 | <?php |
||
17 | class ApcuProxy implements ProxyInterface |
||
18 | { |
||
19 | /** |
||
20 | * @var AbstractAdapter |
||
21 | */ |
||
22 | protected $adapter; |
||
23 | |||
24 | /** |
||
25 | * {@inheritdoc} |
||
26 | */ |
||
27 | 1 | public function getFunctions() |
|
46 | |||
47 | /** |
||
48 | * {@inheritdoc} |
||
49 | 2 | */ |
|
50 | public function setAdapter(AbstractAdapter $adapter) |
||
54 | |||
55 | /** |
||
56 | * Caches a variable in the data store, only if it's not already stored |
||
57 | * |
||
58 | * Note: Unlike many other mechanisms in PHP, variables stored using apcu_add() will persist between requests |
||
59 | * (until the value is removed from the cache). |
||
60 | * |
||
61 | * @since 3.0.13 |
||
62 | * @param mixed $key Store the variable using this name. keys are cache-unique, so attempting to use apc_add() to |
||
63 | * store data with a key that already exists will not overwrite the existing data, and will |
||
64 | * instead return FALSE. (This is the only difference between apcu_add() and apc_store().) |
||
65 | * If $key is an array set Names in key, variables in value |
||
66 | * @param mixed $var The variable to store |
||
67 | * If $key is an array, this parameter is unused and set to NULL |
||
68 | * @param int $ttl Time To Live; store var in the cache for ttl seconds. After the ttl has passed, the stored |
||
69 | * variable will be expunged from the cache (on the next request). If no ttl is supplied |
||
70 | * (or if the ttl is 0), the value will persist until it is removed from the cache manually, |
||
71 | * or otherwise fails to exist in the cache (clear, restart, etc.). |
||
72 | * @return mixed |
||
73 | 2 | */ |
|
74 | public function apcu_add($key, $var = null, $ttl = 0) |
||
90 | |||
91 | /** |
||
92 | * Updates an old value with a new value |
||
93 | * apcu_cas() updates an already existing integer value if the old parameter matches the currently stored value with the value of the new parameter. |
||
94 | * |
||
95 | * @since 3.1.1 |
||
96 | * @param string $key The key of the value being updated. |
||
97 | * @param int $old The old value (the value currently stored). |
||
98 | * @param int $new The new value to update to |
||
99 | * @return boolean Returns TRUE on success or FALSE on failure. |
||
100 | 1 | */ |
|
101 | public function apcu_cas($key, $old, $new) |
||
113 | |||
114 | /** |
||
115 | * Retrieves cached information from APCu's data store |
||
116 | * |
||
117 | * @since 2.0.0 |
||
118 | * @param boolean $limited If limited is TRUE, the return value will exclude the individual list of cache |
||
119 | * entries. This is useful when trying to optimize calls for statistics gathering. |
||
120 | * @return boolean Array of cached data (and meta-data) or FALSE on failure |
||
121 | 1 | */ |
|
122 | public function apcu_cache_info($limited = false) |
||
132 | |||
133 | /** |
||
134 | * Retrieves caches keys & TTL from APCu's data store |
||
135 | * |
||
136 | * @since 3.1.1 |
||
137 | * |
||
138 | * @param null|string $regexp If is regex the return contains keys & ttl of entries found by regex, otherwise - |
||
139 | * keys & ttl of all entries |
||
140 | * |
||
141 | * @return boolean|array Array of cached data's keys and ttl or FALSE on failure |
||
142 | */ |
||
143 | public function apcu_regexp_get_keys($regexp = null) |
||
166 | 1 | ||
167 | /** |
||
168 | 1 | * Clears the user/system cache |
|
169 | 1 | * |
|
170 | 1 | * @since 2.0.0 |
|
171 | * @return boolean Always returns true |
||
172 | 1 | */ |
|
173 | public function apcu_clear_cache() |
||
180 | |||
181 | /** |
||
182 | 1 | * Decrease a stored number |
|
183 | * |
||
184 | 1 | * @since 3.1.1 |
|
185 | 1 | * @param string $key The key of the value being decreased. |
|
186 | 1 | * @param int $step The step, or value to decrease. |
|
187 | 1 | * @param \stdClass $ref success is set to TRUE in success and FALSE in failure |
|
188 | 1 | * @return mixed Returns the current value of key's value on success, or FALSE on failure |
|
189 | */ |
||
190 | 1 | public function apcu_dec($key, $step = 1, $ref = false) |
|
209 | 1 | ||
210 | /** |
||
211 | * Removes a stored variable from the cache |
||
212 | * |
||
213 | * @since 3.1.1 |
||
214 | * @param mixed $key The key used to store the value (with apcu_store()). |
||
215 | * @return mixed Returns TRUE on success or FALSE on failure. |
||
216 | */ |
||
217 | public function apcu_delete($key) |
||
227 | 1 | ||
228 | /** |
||
229 | 1 | * Retrieves caches keys & TTL from APCu's data store |
|
230 | 1 | * |
|
231 | 1 | * @since 3.1.1 |
|
232 | * |
||
233 | 1 | * @param null|string $regexp If is regex removes caches with keys found by regex, |
|
234 | * otherwise - removes all entries |
||
235 | * |
||
236 | * @return boolean Return result |
||
237 | */ |
||
238 | public function apcu_regexp_delete($regexp = null) |
||
252 | 1 | ||
253 | 1 | /** |
|
254 | 1 | * Checks if one or more APCu keys exist. |
|
255 | * |
||
256 | 1 | * @since 3.1.4 |
|
257 | * @param mixed $keys A string, or an array of strings, that contain keys. |
||
258 | 1 | * @return mixed Returns TRUE if the key exists, otherwise FALSE Or if an array was passed to keys, then an |
|
259 | 1 | * array is returned that contains all existing keys, or an empty array if none exist. |
|
260 | 1 | */ |
|
261 | public function apcu_exists($keys) |
||
271 | |||
272 | /** |
||
273 | 1 | * Fetch a stored variable from the cache |
|
274 | * |
||
275 | 1 | * @since 3.0.0 |
|
276 | 1 | * @param mixed $key The key used to store the value (with apcu_store()). If an array is passed then each element is fetched and returned. |
|
277 | 1 | * @param \stdClass $ref success is set to TRUE in success and FALSE in failure |
|
278 | 1 | * @return mixed The stored variable or array of variables on success; FALSE on failure |
|
279 | 1 | */ |
|
280 | public function apcu_fetch($key, $ref = false) |
||
295 | |||
296 | /** |
||
297 | * Increase a stored number |
||
298 | * |
||
299 | * @since 3.1.1 |
||
300 | * @param string $key The key of the value being increased. |
||
301 | * @param int $step The step, or value to increased. |
||
302 | 1 | * @param \stdClass $ref success is set to TRUE in success and FALSE in failure |
|
303 | * @return mixed Returns the current value of key's value on success, or FALSE on failure |
||
304 | 1 | */ |
|
305 | 1 | public function apcu_inc($key, $step = 1, $ref = false) |
|
324 | |||
325 | /** |
||
326 | * Retrieves APCu's Shared Memory Allocation information |
||
327 | * |
||
328 | * @since 2.0.0 |
||
329 | * @param boolean $limited When set to FALSE (default) apcu_sma_info() will return a detailed information about |
||
330 | * each segment. |
||
331 | * @return boolean Array of Shared Memory Allocation data; FALSE on failure |
||
332 | */ |
||
333 | public function apcu_sma_info($limited = false) |
||
343 | |||
344 | /** |
||
345 | * Cache a variable in the data store |
||
346 | * |
||
347 | * Note: Unlike many other mechanisms in PHP, variables stored using apcu_store() will persist between requests |
||
348 | * (until the value is removed from the cache). |
||
349 | * |
||
350 | * @since 3.0.0 |
||
351 | * @param mixed $key Store the variable using this name. keys are cache-unique, so storing a second value with the |
||
352 | * same key will overwrite the original value. |
||
353 | * If $key is an array set Names in key, variables in value |
||
354 | * @param mixed $var The variable to store |
||
355 | * If $key is an array, this parameter is unused and set to NULL |
||
356 | * @param int $ttl Time To Live; store var in the cache for ttl seconds. After the ttl has passed, the stored |
||
357 | * variable will be expunged from the cache (on the next request). If no ttl is supplied (or if |
||
358 | * the ttl is 0), the value will persist until it is removed from the cache manually, or |
||
359 | * otherwise fails to exist in the cache (clear, restart, etc.). |
||
360 | * @return boolean Returns TRUE on success or FALSE on failure. Second syntax returns array with error keys. |
||
361 | */ |
||
362 | public function apcu_store($key, $var = null, $ttl = 0) |
||
374 | |||
375 | /** |
||
376 | * @return string |
||
377 | */ |
||
378 | public function apcu_version() |
||
385 | } |
||
386 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: