From c31de8791dff36708375550ccc0f6ebf211e5fdd Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Tue, 19 Jun 2018 16:22:28 -0700 Subject: [PATCH] (dev/core#174) CRM_Utils_Cache_Interface::clear() is an alias for flush() flush() is specified by Civi's traditional interface, and clear() is specified by PSR-16. The semantics should be the same (i.e. remove any records managed by this cache-object). This treats flush() and clear() as aliases. --- CRM/Utils/Cache/APCcache.php | 4 ++++ CRM/Utils/Cache/ArrayCache.php | 4 ++++ CRM/Utils/Cache/Interface.php | 16 ++++++++++++++++ CRM/Utils/Cache/Memcache.php | 4 ++++ CRM/Utils/Cache/Memcached.php | 4 ++++ CRM/Utils/Cache/NoCache.php | 4 ++++ CRM/Utils/Cache/Redis.php | 4 ++++ CRM/Utils/Cache/SerializeCache.php | 4 ++++ CRM/Utils/Cache/SqlGroup.php | 4 ++++ 9 files changed, 48 insertions(+) diff --git a/CRM/Utils/Cache/APCcache.php b/CRM/Utils/Cache/APCcache.php index 0a3d3ee4b3..d0047b857f 100644 --- a/CRM/Utils/Cache/APCcache.php +++ b/CRM/Utils/Cache/APCcache.php @@ -127,4 +127,8 @@ class CRM_Utils_Cache_APCcache implements CRM_Utils_Cache_Interface { return TRUE; } + public function clear() { + return $this->flush(); + } + } diff --git a/CRM/Utils/Cache/ArrayCache.php b/CRM/Utils/Cache/ArrayCache.php index 150f9f7cc0..47ad9a082d 100644 --- a/CRM/Utils/Cache/ArrayCache.php +++ b/CRM/Utils/Cache/ArrayCache.php @@ -94,4 +94,8 @@ class CRM_Utils_Cache_Arraycache implements CRM_Utils_Cache_Interface { return TRUE; } + public function clear() { + return $this->flush(); + } + } diff --git a/CRM/Utils/Cache/Interface.php b/CRM/Utils/Cache/Interface.php index 06cf63b5e4..52e4f11412 100644 --- a/CRM/Utils/Cache/Interface.php +++ b/CRM/Utils/Cache/Interface.php @@ -88,8 +88,24 @@ interface CRM_Utils_Cache_Interface { /** * Delete all values from the cache. * + * NOTE: flush() and clear() should be aliases. flush() is specified by + * Civi's traditional interface, and clear() is specified by PSR-16. + * * @return bool + * @see clear + * @deprecated */ public function flush(); + /** + * Delete all values from the cache. + * + * NOTE: flush() and clear() should be aliases. flush() is specified by + * Civi's traditional interface, and clear() is specified by PSR-16. + * + * @return bool + * @see flush + */ + public function clear(); + } diff --git a/CRM/Utils/Cache/Memcache.php b/CRM/Utils/Cache/Memcache.php index 3fcc631575..23889f5fe7 100644 --- a/CRM/Utils/Cache/Memcache.php +++ b/CRM/Utils/Cache/Memcache.php @@ -157,4 +157,8 @@ class CRM_Utils_Cache_Memcache implements CRM_Utils_Cache_Interface { return $this->_cache->flush(); } + public function clear() { + return $this->flush(); + } + } diff --git a/CRM/Utils/Cache/Memcached.php b/CRM/Utils/Cache/Memcached.php index ff869f919e..7b9bcfeaf5 100644 --- a/CRM/Utils/Cache/Memcached.php +++ b/CRM/Utils/Cache/Memcached.php @@ -179,4 +179,8 @@ class CRM_Utils_Cache_Memcached implements CRM_Utils_Cache_Interface { return $this->_cache->flush(); } + public function clear() { + return $this->flush(); + } + } diff --git a/CRM/Utils/Cache/NoCache.php b/CRM/Utils/Cache/NoCache.php index c0d7523c3a..1fdaef4e99 100644 --- a/CRM/Utils/Cache/NoCache.php +++ b/CRM/Utils/Cache/NoCache.php @@ -90,4 +90,8 @@ class CRM_Utils_Cache_NoCache implements CRM_Utils_Cache_Interface { return FALSE; } + public function clear() { + return $this->flush(); + } + } diff --git a/CRM/Utils/Cache/Redis.php b/CRM/Utils/Cache/Redis.php index f18d3b8d8b..0cc979abcc 100644 --- a/CRM/Utils/Cache/Redis.php +++ b/CRM/Utils/Cache/Redis.php @@ -172,4 +172,8 @@ class CRM_Utils_Cache_Redis implements CRM_Utils_Cache_Interface { return TRUE; } + public function clear() { + return $this->flush(); + } + } diff --git a/CRM/Utils/Cache/SerializeCache.php b/CRM/Utils/Cache/SerializeCache.php index f0e7d5ca49..910fe1bf7e 100644 --- a/CRM/Utils/Cache/SerializeCache.php +++ b/CRM/Utils/Cache/SerializeCache.php @@ -139,4 +139,8 @@ class CRM_Utils_Cache_SerializeCache implements CRM_Utils_Cache_Interface { return TRUE; } + public function clear() { + return $this->flush(); + } + } diff --git a/CRM/Utils/Cache/SqlGroup.php b/CRM/Utils/Cache/SqlGroup.php index 6bfd8d039a..91237b5847 100644 --- a/CRM/Utils/Cache/SqlGroup.php +++ b/CRM/Utils/Cache/SqlGroup.php @@ -149,6 +149,10 @@ class CRM_Utils_Cache_SqlGroup implements CRM_Utils_Cache_Interface { return TRUE; } + public function clear() { + return $this->flush(); + } + public function prefetch() { $this->frontCache = CRM_Core_BAO_Cache::getItems($this->group, $this->componentID); } -- 2.25.1