You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
thrownewInvalidArgumentException(sprintf('"%s" is not a subclass of "Redis"', $class));
110
+
} else {
111
+
thrownewInvalidArgumentException(sprintf('Class "%s" does not exist', $class));
109
112
}
110
113
111
114
return$redis;
@@ -119,10 +122,10 @@ protected function doFetch(array $ids)
119
122
$result = array();
120
123
121
124
if ($ids) {
122
-
$values = $this->redis->mget($ids);
125
+
$values = $this->redis->mGet($ids);
123
126
$index = 0;
124
127
foreach ($idsas$id) {
125
-
if (false !== $value = $values[$index++]) {
128
+
if ($value = $values[$index++]) {
126
129
$result[$id] = unserialize($value);
127
130
}
128
131
}
@@ -144,14 +147,16 @@ protected function doHave($id)
144
147
*/
145
148
protectedfunctiondoClear($namespace)
146
149
{
150
+
// As documented in Redis documentation (http://redis.io/commands/keys) using KEYS
151
+
// can hang your server when it is executed against large databases (millions of items).
152
+
// Whenever you hit this scale, it is advised to deploy one Redis database per cache pool
153
+
// instead of using namespaces, so that FLUSHDB is used instead.
154
+
$lua = "local keys=redis.call('KEYS',ARGV[1]..'*') for i=1,#keys,5000 do redis.call('DEL',unpack(keys,i,math.min(i+4999,#keys))) end";
155
+
147
156
if (!isset($namespace[0])) {
148
-
$this->redis->flushDB();
157
+
$this->redis->flushDb();
149
158
} else {
150
-
// As documented in Redis documentation (http://redis.io/commands/keys) using KEYS
151
-
// can hang your server when it is executed against large databases (millions of items).
152
-
// Whenever you hit this scale, it is advised to deploy one Redis database per cache pool
153
-
// instead of using namespaces, so that the above FLUSHDB is used instead.
154
-
$this->redis->eval(sprintf("local keys=redis.call('KEYS','%s*') for i=1,#keys,5000 do redis.call('DEL',unpack(keys,i,math.min(i+4999,#keys))) end", $namespace));
159
+
$this->redis->eval($lua, array($namespace), 0);
155
160
}
156
161
157
162
returntrue;
@@ -189,11 +194,11 @@ protected function doSave(array $values, $lifetime)
0 commit comments