From 53302223ecc272984070fc17a48bffaf0c68b6d1 Mon Sep 17 00:00:00 2001 From: Trigur Date: Wed, 21 Mar 2018 15:24:49 +0300 Subject: [PATCH] Manual cache clear in CacheableRepository --- .../Repository/Traits/CacheableRepository.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Prettus/Repository/Traits/CacheableRepository.php b/src/Prettus/Repository/Traits/CacheableRepository.php index 28b229d5..efc6a669 100644 --- a/src/Prettus/Repository/Traits/CacheableRepository.php +++ b/src/Prettus/Repository/Traits/CacheableRepository.php @@ -340,4 +340,18 @@ public function getByCriteria(CriteriaInterface $criteria) $this->resetScope(); return $value; } + + /** + * Clear cache + * + * @return void + */ + public function clearCache() + { + $keys = CacheKeys::getKeys(get_called_class()); + + foreach ($keys as $key) { + $this->getCacheRepository()->forget($key); + } + } }