Skip to content

Commit

Permalink
Merge pull request #118 from squatto/patch-1
Browse files Browse the repository at this point in the history
Get cache tags once when invalidating
  • Loading branch information
rennokki authored Feb 3, 2022
2 parents f09d415 + 7bd849c commit 8e29612
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/FlushQueryCacheObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,12 @@ protected function invalidateCache(Model $model, $relation = null, $pivotedModel
{
$class = get_class($model);

if (! $model->getCacheTagsToInvalidateOnUpdate($relation, $pivotedModels)) {
$tags = $model->getCacheTagsToInvalidateOnUpdate($relation, $pivotedModels);

if (! $tags) {
throw new Exception('Automatic invalidation for '.$class.' works only if at least one tag to be invalidated is specified.');
}

$class::flushQueryCache(
$model->getCacheTagsToInvalidateOnUpdate($relation, $pivotedModels)
);
$class::flushQueryCache($tags);
}
}

0 comments on commit 8e29612

Please sign in to comment.