Skip to content
Permalink
Browse files

bug #30515 [Cache] Only delete one key at a time when on Predis + Clu…

…ster (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
  • Loading branch information...
nicolas-grekas committed Mar 11, 2019
2 parents f038da0 + f5ece20 commit 21d01973f764df157fab4337b7b2c0b0748371dd
Showing with 11 additions and 1 deletion.
  1. +11 −1 src/Symfony/Component/Cache/Traits/RedisTrait.php
@@ -272,7 +272,17 @@ protected function doClear($namespace)
*/
protected function doDelete(array $ids)
{
if ($ids) {
if (!$ids) {
return true;
}
if ($this->redis instanceof \Predis\Client && $this->redis->getConnection() instanceof ClusterInterface) {
$this->pipeline(function () use ($ids) {
foreach ($ids as $id) {
yield 'del' => [$id];
}
})->rewind();
} else {
$this->redis->del($ids);
}

0 comments on commit 21d0197

Please sign in to comment.
You can’t perform that action at this time.