1 | <?php |
||
22 | class PredisStorage implements StorageInterface |
||
23 | { |
||
24 | /** |
||
25 | * @var Client |
||
26 | */ |
||
27 | protected $client; |
||
28 | |||
29 | /** |
||
30 | * Sets up the class using the redis instance connected to the predis $client. |
||
31 | * @param Predis\Client $client |
||
32 | * @param array $options an array of options |
||
33 | * @see BehEh\Flaps\PredisStorage::configure |
||
34 | */ |
||
35 | public function __construct(Client $client, array $options = array()) |
||
40 | |||
41 | /** |
||
42 | * @var array |
||
43 | */ |
||
44 | protected $options; |
||
45 | |||
46 | /** |
||
47 | * Configures this class with some options: |
||
48 | * <table> |
||
49 | * <tr><th>prefix</th><td>the prefix to apply to all unique keys</td></tr> |
||
50 | * </table> |
||
51 | * @param array $options the key value pairs of options for this class |
||
52 | */ |
||
53 | public function configure(array $options) |
||
54 | { |
||
55 | $this->options = array_merge(array( |
||
56 | 'prefix' => 'flaps:' |
||
57 | ), $options); |
||
58 | } |
||
59 | |||
60 | private function prefixKey($key) |
||
64 | |||
65 | private function prefixTimestamp($timestamp) |
||
69 | |||
70 | 1 | public function setValue($key, $value) |
|
74 | |||
75 | 1 | public function incrementValue($key) |
|
79 | |||
80 | 1 | public function getValue($key) |
|
84 | |||
85 | 1 | public function setTimestamp($key, $timestamp) |
|
89 | |||
90 | 1 | public function getTimestamp($key) |
|
94 | |||
95 | 3 | public function expire($key) |
|
100 | |||
101 | 1 | public function expireIn($key, $seconds) |
|
108 | } |
||
109 |