From: Tim Otten Date: Fri, 4 Jan 2019 03:31:04 +0000 (-0800) Subject: (dev/core#635) Only write extra prevnext cache record if used X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=e37c68e1f41946f2e038a756dc7959ae4efdbd72;p=civicrm-core.git (dev/core#635) Only write extra prevnext cache record if used This line of code creates an extra record to facilitate clearing the SQL-based prevnext cache. However, with Redis-based prevnext cache, it's not needed because the Redis implementation simply uses a TTL -- and (on Redis deployments) this lines to gratuitous SQL writes. --- diff --git a/CRM/Campaign/Selector/Search.php b/CRM/Campaign/Selector/Search.php index 94a5cb5731..d7ed429ba5 100644 --- a/CRM/Campaign/Selector/Search.php +++ b/CRM/Campaign/Selector/Search.php @@ -294,8 +294,10 @@ FROM {$from} return; } - // also record an entry in the cache key table, so we can delete it periodically - CRM_Core_BAO_Cache::setItem($cacheKey, 'CiviCRM Search PrevNextCache', $cacheKey); + if (Civi::service('prevnext') instanceof CRM_Core_PrevNextCache_Sql) { + // SQL-backed prevnext cache uses an extra record for pruning the cache. + CRM_Core_BAO_Cache::setItem($cacheKey, 'CiviCRM Search PrevNextCache', $cacheKey); + } } } diff --git a/CRM/Contact/Selector.php b/CRM/Contact/Selector.php index 9418ff2282..8be026f626 100644 --- a/CRM/Contact/Selector.php +++ b/CRM/Contact/Selector.php @@ -1062,8 +1062,10 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se } } - // also record an entry in the cache key table, so we can delete it periodically - CRM_Core_BAO_Cache::setItem($cacheKey, 'CiviCRM Search PrevNextCache', $cacheKey); + if (Civi::service('prevnext') instanceof CRM_Core_PrevNextCache_Sql) { + // SQL-backed prevnext cache uses an extra record for pruning the cache. + CRM_Core_BAO_Cache::setItem($cacheKey, 'CiviCRM Search PrevNextCache', $cacheKey); + } } /**