From a8c2d057ee826b1e4ca373710857f4a705a7da59 Mon Sep 17 00:00:00 2001 From: Mirko Pagliai Date: Fri, 25 Mar 2016 14:47:39 +0100 Subject: [PATCH] added `clearAll()` method --- src/Cache/Cache.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/Cache/Cache.php b/src/Cache/Cache.php index 70fcfdcf8ad..9154d96418d 100644 --- a/src/Cache/Cache.php +++ b/src/Cache/Cache.php @@ -445,6 +445,25 @@ public static function clear($check = false, $config = 'default') $engine = static::engine($config); return $engine->clear($check); } + + /** + * Delete all keys from the cache from all configurations. + * + * @param bool $check if true will check expiration, otherwise delete all + * @return bool True if the cache of all configurations was successfully cleared, false otherwise + */ + public static function clearAll($check = false) + { + $success = true; + + foreach (self::configured() as $config) { + if (!self::clear($check, $config)) { + $success = false; + } + } + + return $success; + } /** * Delete all keys from the cache belonging to the same group.