Skip to content

Commit

Permalink
Merge pull request #21 from syamsoul/bugfix/cache-indefinitely
Browse files Browse the repository at this point in the history
should not cached if $cache_timeout=0
  • Loading branch information
syamsoul authored Aug 25, 2024
2 parents a7d689d + 6464557 commit 010c083
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Handler/ResponseHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ public function json(int $cache_timeout = 0, string $extend_cache_name = ''): Js

$frontend_framework = $this->handler->frontend()->getFramework();

$data = Cache::remember(hash('sha256', $full_cache_name), $cache_timeout, fn () => $this->handler->data()->getData());
if ($cache_timeout > 0) {
$data = Cache::remember(hash('sha256', $full_cache_name), $cache_timeout, fn () => $this->handler->data()->getData());
} else {
$data = $this->handler->data()->getData();
}

if ($frontend_framework === 'datatablejs') {
return response()->json($data);
Expand Down

0 comments on commit 010c083

Please sign in to comment.