Skip to content

Commit

Permalink
- add tags to WithCachedRows livewire trait
Browse files Browse the repository at this point in the history
  • Loading branch information
joshtorres committed Nov 21, 2023
1 parent ca72720 commit c1d6b45
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/Livewire/WithCachedRows.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit c1d6b45

Please sign in to comment.