-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathDualRedis.php
50 lines (43 loc) · 1 KB
/
DualRedis.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
/* vim: set ts=4 sw=4 tw=0 et :*/
class sspmod_redis_Redis_DualRedis
{
public function __construct($oldHost, $newHost)
{
$this->oldHost = $oldHost;
$this->newHost = $newHost;
}
public function get($key)
{
$res = $this->newHost->get($key);
if (is_null($res)) {
$res = $this->oldHost->get($key);
}
return $res;
}
public function set($key, $value)
{
$this->newHost->set($key, $value);
}
public function auth($key)
{
$this->newHost->auth($key);
$this->oldHost->auth($key);
}
public function keys($pattern)
{
return array_unique(array_merge(
$this->newHost->keys($pattern),
$this->oldHost->keys($pattern)
));
}
public function del($key)
{
$this->newHost->del($key);
$this->oldHost->del($key);
}
public function expireat($key, $timestamp)
{
$this->newHost->expireat($key, $timestamp);
}
}