From c1d6b459eaf7c476d2b444a61aa375f5f35111dc Mon Sep 17 00:00:00 2001 From: Josh Torres Date: Tue, 21 Nov 2023 12:38:37 -0500 Subject: [PATCH] - add tags to WithCachedRows livewire trait --- src/Livewire/WithCachedRows.php | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/Livewire/WithCachedRows.php b/src/Livewire/WithCachedRows.php index 54256cb..8776ef4 100644 --- a/src/Livewire/WithCachedRows.php +++ b/src/Livewire/WithCachedRows.php @@ -35,21 +35,16 @@ public function cache($callback) { $cacheKey = $this->getCacheKey(); $cache = cache(); + if (! empty($this->tags)) { + $cache = $cache->tags($this->tags); + } if ($this->useCache && $cache->has($cacheKey)) { - if (! empty($this->tags)) { - $cache = $cache->tags($this->tags); - } - return $cache->get($cacheKey); } $result = $callback(); - if (! empty($this->tags)) { - $cache = $cache->tags($this->tags); - } - $cache->put($cacheKey, $result, $this->getCacheTtl()); return $result;