1 | <?php |
||
9 | class Predis implements Memoize |
||
10 | { |
||
11 | /** |
||
12 | * The predis client |
||
13 | * |
||
14 | * @var \Predis\Client |
||
15 | */ |
||
16 | private $_client; |
||
17 | |||
18 | /** |
||
19 | * Cache refresh |
||
20 | * |
||
21 | * @var boolean |
||
22 | */ |
||
23 | private $_refresh; |
||
24 | |||
25 | /** |
||
26 | * Sets the predis client. |
||
27 | * |
||
28 | * @param \Predis\Client $client The predis client to use |
||
29 | * @param boolean $refresh If true we will always overwrite cache even if it is already set |
||
30 | */ |
||
31 | public function __construct(Client $client, $refresh = false) |
||
36 | |||
37 | /** |
||
38 | * The value is stored in redis as a json_encoded string, so make sure that the value you return from $compute is json-encodable. |
||
39 | * |
||
40 | * @see Memoize::memoizeCallable |
||
41 | */ |
||
42 | public function memoizeCallable($key, $compute, $cacheTime = null) |
||
62 | |||
63 | /** |
||
64 | * Caches the value into redis with errors suppressed. |
||
65 | * |
||
66 | * @param string $key The key. |
||
67 | * @param string $value The value. |
||
68 | * @param int $cacheTime The optional cache time |
||
69 | * @return void |
||
70 | */ |
||
71 | private function _cache($key, $value, $cacheTime = null) |
||
84 | } |
||
85 |