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
@@ -39,18 +37,13 @@ public function __construct(\Redis $redisConnection, $namespace = '', $defaultLi
39
37
protectedfunctiondoFetch(array$ids)
40
38
{
41
39
$values = $this->redis->mget($ids);
42
-
43
40
$index = 0;
44
41
$result = [];
45
42
46
43
foreach ($idsas$id) {
47
-
$value = $values[$index++];
48
-
49
-
if (false === $value) {
50
-
continue;
44
+
if (false !== $value = $values[$index++]) {
45
+
$result[$id] = unserialize($value);
51
46
}
52
-
53
-
$result[$id] = unserialize($value);
54
47
}
55
48
56
49
return$result;
@@ -67,9 +60,19 @@ protected function doHave($id)
67
60
/**
68
61
* {@inheritdoc}
69
62
*/
70
-
protectedfunctiondoClear()
63
+
protectedfunctiondoClear($namespace)
71
64
{
72
-
return$this->redis->flushDB();
65
+
if (!isset($namespace[0])) {
66
+
$this->redis->flushDB();
67
+
} else {
68
+
// As documented in Redis documentation (http://redis.io/commands/keys) using KEYS
69
+
// can hang your server when it is executed against large databases (millions of items).
70
+
// Whenever you hit this scale, it is advised to deploy one Redis database per cache pool
71
+
// instead of using namespaces, so that the above FLUSHDB is used instead.
72
+
$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));
73
+
}
74
+
75
+
returntrue;
73
76
}
74
77
75
78
/**
@@ -87,21 +90,26 @@ protected function doDelete(array $ids)
0 commit comments