From 77086d2be5d1cac7d106f704f67397e42ab0fa96 Mon Sep 17 00:00:00 2001 From: Tomasz Narloch Date: Thu, 18 Aug 2016 17:23:54 +0200 Subject: [PATCH] Add flush method to storages --- libraries/joomla/cache/storage.php | 12 ++++++++++++ libraries/joomla/cache/storage/memcache.php | 17 +++++++++++++++++ libraries/joomla/cache/storage/memcached.php | 17 +++++++++++++++++ tests/unit/core/case/cache.php | 2 ++ 4 files changed, 48 insertions(+) diff --git a/libraries/joomla/cache/storage.php b/libraries/joomla/cache/storage.php index 8d13425449a30..07747c9c196a0 100644 --- a/libraries/joomla/cache/storage.php +++ b/libraries/joomla/cache/storage.php @@ -253,6 +253,18 @@ public function clean($group, $mode = null) return true; } + /** + * Flush all existing items in storage. + * + * @return boolean + * + * @since __DEPLOY_VERSION__ + */ + public function flush() + { + return true; + } + /** * Garbage collect expired cache data * diff --git a/libraries/joomla/cache/storage/memcache.php b/libraries/joomla/cache/storage/memcache.php index 77fd7c3caf5ad..40f402eac46d6 100644 --- a/libraries/joomla/cache/storage/memcache.php +++ b/libraries/joomla/cache/storage/memcache.php @@ -278,6 +278,23 @@ public function clean($group, $mode = null) return true; } + /** + * Flush all existing items in storage. + * + * @return boolean + * + * @since __DEPLOY_VERSION__ + */ + public function flush() + { + if (!$this->lockindex()) + { + return false; + } + + return static::$_db->flush(); + } + /** * Test to see if the storage handler is available. * diff --git a/libraries/joomla/cache/storage/memcached.php b/libraries/joomla/cache/storage/memcached.php index 966dac936647b..391644adf01dc 100644 --- a/libraries/joomla/cache/storage/memcached.php +++ b/libraries/joomla/cache/storage/memcached.php @@ -294,6 +294,23 @@ public function clean($group, $mode = null) return true; } + /** + * Flush all existing items in storage. + * + * @return boolean + * + * @since __DEPLOY_VERSION__ + */ + public function flush() + { + if (!$this->lockindex()) + { + return false; + } + + return static::$_db->flush(); + } + /** * Test to see if the storage handler is available. * diff --git a/tests/unit/core/case/cache.php b/tests/unit/core/case/cache.php index 9c3eef9b677cb..51d856e2d08d4 100644 --- a/tests/unit/core/case/cache.php +++ b/tests/unit/core/case/cache.php @@ -62,7 +62,9 @@ protected function tearDown() if ($this->handler instanceof JCacheStorage) { + // Deprecated, temporary have to stay because flush method is not implemented in all storages. $this->handler->clean($this->group); + $this->handler->flush(); } parent::tearDown();