From 21c8278fe1128737fdc6cf7a830aad385b3dba1e Mon Sep 17 00:00:00 2001 From: Ryan Mitchell Date: Tue, 9 Mar 2021 07:49:01 +0000 Subject: [PATCH 1/3] Add support for cache tags param --- src/Tags/Cache.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/Tags/Cache.php b/src/Tags/Cache.php index a487ce115a..0b6f995729 100644 --- a/src/Tags/Cache.php +++ b/src/Tags/Cache.php @@ -13,11 +13,22 @@ public function index() return []; } - if ($cached = LaraCache::get($key = $this->getCacheKey())) { - return $cached; - } + if (count($cacheTags = $this->params->explode('tags', [])) < 1) { + + if ($cached = LaraCache::get($key = $this->getCacheKey())) { + return $cached; + } + + LaraCache::put($key, $html = (string) $this->parse([]), $this->getCacheLength()); - LaraCache::put($key, $html = (string) $this->parse([]), $this->getCacheLength()); + } else { + + if ($cached = LaraCache::tags($cacheTags)->get($key = $this->getCacheKey())) { + return $cached; + } + + LaraCache::tags($cacheTags)->put($key, $html = (string) $this->parse([]), $this->getCacheLength()); + } return $html; } From a252bff4fe778e433abf4dc8e911ab920f65caf9 Mon Sep 17 00:00:00 2001 From: Ryan Mitchell Date: Tue, 9 Mar 2021 07:51:00 +0000 Subject: [PATCH 2/3] StyleCI --- src/Tags/Cache.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Tags/Cache.php b/src/Tags/Cache.php index 0b6f995729..9ebcedf0af 100644 --- a/src/Tags/Cache.php +++ b/src/Tags/Cache.php @@ -14,15 +14,12 @@ public function index() } if (count($cacheTags = $this->params->explode('tags', [])) < 1) { - if ($cached = LaraCache::get($key = $this->getCacheKey())) { return $cached; } LaraCache::put($key, $html = (string) $this->parse([]), $this->getCacheLength()); - } else { - if ($cached = LaraCache::tags($cacheTags)->get($key = $this->getCacheKey())) { return $cached; } From 3a08eb556f78a238f702f35ad68a4bcde565aa84 Mon Sep 17 00:00:00 2001 From: Jason Varga Date: Tue, 6 Apr 2021 16:06:24 -0400 Subject: [PATCH 3/3] clean up --- src/Tags/Cache.php | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/Tags/Cache.php b/src/Tags/Cache.php index 9ebcedf0af..8ac7e1215b 100644 --- a/src/Tags/Cache.php +++ b/src/Tags/Cache.php @@ -13,20 +13,18 @@ public function index() return []; } - if (count($cacheTags = $this->params->explode('tags', [])) < 1) { - if ($cached = LaraCache::get($key = $this->getCacheKey())) { - return $cached; - } - - LaraCache::put($key, $html = (string) $this->parse([]), $this->getCacheLength()); - } else { - if ($cached = LaraCache::tags($cacheTags)->get($key = $this->getCacheKey())) { - return $cached; - } - - LaraCache::tags($cacheTags)->put($key, $html = (string) $this->parse([]), $this->getCacheLength()); + $store = LaraCache::store(); + + if (count($tags = $this->params->explode('tags', []))) { + $store = $store->tags($tags); + } + + if ($cached = $store->get($key = $this->getCacheKey())) { + return $cached; } + $store->put($key, $html = (string) $this->parse([]), $this->getCacheLength()); + return $html; }