From 737c159e2d38d5139ed4ea976ba063432663e7a6 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Tue, 22 Aug 2023 09:22:24 +1200 Subject: [PATCH] Only delete contact from sub-Redis keys if the 'all' key contains the contact --- CRM/Core/PrevNextCache/Redis.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/CRM/Core/PrevNextCache/Redis.php b/CRM/Core/PrevNextCache/Redis.php index 5b70cf74dc..3705cef53c 100644 --- a/CRM/Core/PrevNextCache/Redis.php +++ b/CRM/Core/PrevNextCache/Redis.php @@ -173,9 +173,12 @@ class CRM_Core_PrevNextCache_Redis implements CRM_Core_PrevNextCache_Interface { } elseif ($id !== NULL && $cacheKey !== NULL) { // Delete a specific contact, within a specific cache. - $this->redis->zRem($this->key($cacheKey, 'all'), $id); - $this->redis->zRem($this->key($cacheKey, 'sel'), $id); - $this->redis->hDel($this->key($cacheKey, 'data'), $id); + $deleted = $this->redis->zRem($this->key($cacheKey, 'all'), $id); + if ($deleted) { + // If they were in the 'all' key they might be in the more specific 'sel' and 'data' keys. + $this->redis->zRem($this->key($cacheKey, 'sel'), $id); + $this->redis->hDel($this->key($cacheKey, 'data'), $id); + } } elseif ($id !== NULL && $cacheKey === NULL) { // Delete a specific contact, across all prevnext caches. -- 2.25.1