@@ -22,11 +22,10 @@ class RedisAdapter extends AbstractAdapter
22
22
23
23
public function __construct (\Redis $ redisConnection , $ namespace = '' , $ defaultLifetime = 0 )
24
24
{
25
- $ this ->redis = $ redisConnection ;
26
-
27
25
if (preg_match ('#[^-+_.A-Za-z0-9]# ' , $ namespace , $ match )) {
28
26
throw new InvalidArgumentException (sprintf ('RedisAdapter namespace contains "%s" but only characters in [-+_.A-Za-z0-9] are allowed. ' , $ match [0 ]));
29
27
}
28
+ $ this ->redis = $ redisConnection ;
30
29
31
30
parent ::__construct ($ namespace , $ defaultLifetime );
32
31
}
@@ -36,13 +35,15 @@ public function __construct(\Redis $redisConnection, $namespace = '', $defaultLi
36
35
*/
37
36
protected function doFetch (array $ ids )
38
37
{
39
- $ values = $ this ->redis ->mget ($ ids );
40
- $ index = 0 ;
41
- $ result = [];
42
-
43
- foreach ($ ids as $ id ) {
44
- if (false !== $ value = $ values [$ index ++]) {
45
- $ result [$ id ] = unserialize ($ value );
38
+ $ result = array ();
39
+
40
+ if ($ ids ) {
41
+ $ values = $ this ->redis ->mget ($ ids );
42
+ $ index = 0 ;
43
+ foreach ($ ids as $ id ) {
44
+ if (false !== $ value = $ values [$ index ++]) {
45
+ $ result [$ id ] = unserialize ($ value );
46
+ }
46
47
}
47
48
}
48
49
@@ -80,7 +81,9 @@ protected function doClear($namespace)
80
81
*/
81
82
protected function doDelete (array $ ids )
82
83
{
83
- $ this ->redis ->del ($ ids );
84
+ if ($ ids ) {
85
+ $ this ->redis ->del ($ ids );
86
+ }
84
87
85
88
return true ;
86
89
}
@@ -101,6 +104,9 @@ protected function doSave(array $values, $lifetime)
101
104
}
102
105
}
103
106
107
+ if (!$ serialized ) {
108
+ return $ failed ;
109
+ }
104
110
if ($ lifetime > 0 ) {
105
111
$ pipe = $ this ->redis ->multi (\Redis::PIPELINE );
106
112
foreach ($ serialized as $ id => $ value ) {
0 commit comments