Skip to content

Commit 8e29612

Browse files
authored
Merge pull request #118 from squatto/patch-1
Get cache tags once when invalidating
2 parents f09d415 + 7bd849c commit 8e29612

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/FlushQueryCacheObserver.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,12 @@ protected function invalidateCache(Model $model, $relation = null, $pivotedModel
154154
{
155155
$class = get_class($model);
156156

157-
if (! $model->getCacheTagsToInvalidateOnUpdate($relation, $pivotedModels)) {
157+
$tags = $model->getCacheTagsToInvalidateOnUpdate($relation, $pivotedModels);
158+
159+
if (! $tags) {
158160
throw new Exception('Automatic invalidation for '.$class.' works only if at least one tag to be invalidated is specified.');
159161
}
160162

161-
$class::flushQueryCache(
162-
$model->getCacheTagsToInvalidateOnUpdate($relation, $pivotedModels)
163-
);
163+
$class::flushQueryCache($tags);
164164
}
165165
}

0 commit comments

Comments
 (0)