Skip to content

Commit

Permalink
Ensure isCacheable in checkCooldownAndFlushAfterPersisting (#458)
Browse files Browse the repository at this point in the history
  • Loading branch information
KieranFYI committed Mar 2, 2024
1 parent 19bcdf2 commit da53fcc
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Traits/Caching.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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 (
Expand Down Expand Up @@ -327,7 +335,6 @@ public function isCachable() : bool
}

return $this->isCachable
&& ! $isCacheDisabled
&& $allRelationshipsAreCachable;
}

Expand Down

0 comments on commit da53fcc

Please sign in to comment.