From 15bccaa066086b68e7430663d07c293ead274d8e Mon Sep 17 00:00:00 2001 From: Kieran Anderson Date: Sun, 25 Feb 2024 05:04:28 +0000 Subject: [PATCH] Ensure isCacheable in checkCooldownAndFlushAfterPersisting --- src/Traits/Caching.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Traits/Caching.php b/src/Traits/Caching.php index 5d5fccb..7762a59 100644 --- a/src/Traits/Caching.php +++ b/src/Traits/Caching.php @@ -263,6 +263,10 @@ protected function checkCooldownAndRemoveIfExpired(Model $instance) protected function checkCooldownAndFlushAfterPersisting(Model $instance, string $relationship = "") { + if (!$this->isCachable()) { + return; + } + [$cacheCooldown, $invalidatedAt] = $instance->getModelCacheCooldown($instance); if (! $cacheCooldown) { @@ -295,6 +299,10 @@ public function isCachable() : bool $isCacheDisabled = ! Container::getInstance() ->make("config") ->get("laravel-model-caching.enabled"); + if ($isCacheDisabled) { + return false; + } + $allRelationshipsAreCachable = true; if ( @@ -327,7 +335,6 @@ public function isCachable() : bool } return $this->isCachable - && ! $isCacheDisabled && $allRelationshipsAreCachable; }