10000 bug #30515 [Cache] Only delete one key at a time when on Predis + Clu… · symfony/symfony@21d0197 · GitHub
[go: up one dir, main page]

Skip to content

Commit 21d0197

Browse files
bug #30515 [Cache] Only delete one key at a time when on Predis + Cluster (andrerom)
This PR was merged into the 3.4 branch. Discussion ---------- [Cache] Only delete one key at a time when on Predis + Cluster | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | License | MIT Makes sure deletes when on Predis Cluster is only done one by one as it's not able to send the keys to right cluster node like RedisCluster can. _This is backport of logic from 4.x to fix this. With one tweak; make sure to only do this when on cluster so not all Predis users pay the penalty for it._ Commits ------- f5ece20 [Cache] Only delete one key at a time when on Predis + Cluster
2 parents f038da0 + f5ece20 commit 21d0197

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/Symfony/Component/Cache/Traits/RedisTrait.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,17 @@ protected function doClear($namespace)
272272
*/
273273
protected function doDelete(array $ids)
274274
{
275-
if ($ids) {
275+
if (!$ids) {
276+
return true;
277+
}
278+
279+
if ($this->redis instanceof \Predis\Client && $this->redis->getConnection() instanceof ClusterInterface) {
280+
$this->pipeline(function () use ($ids) {
281+
foreach ($ids as $id) {
282+
yield 'del' => [$id];
283+
}
284+
})->rewind();
285+
} else {
276286
$this->redis->del($ids);
277287
}
278288

0 commit comments

Comments
 (0)
0