Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Get cache tags once when invalidating
I'm using an overridden `getCacheTagsToInvalidateOnUpdate()` to track how many times each tag is invalidated. The way `invalidateCache()` was originally written calls the `getCacheTagsToInvalidateOnUpdate()` method twice, resulting in the tags being counted twice for each invalidation. This change simply assigns the tags to a variable and uses the variable instead of calling the method directly. FWIW, this is what I'm doing to track the tag invalidations. Just a simple array saved to the cache. ```php public function getCacheTagsToInvalidateOnUpdate($relation = null, $pivotedModels = null): array { $tags = $this->getCacheBaseTags(); $invalidations = Cache::get('cache-invalidations', []); foreach ($tags as $tag) { $invalidations[$tag] = ($invalidations[$tag] ?? 0) + 1; } Cache::forever('cache-invalidations', $invalidations); return $tags; } ```
- Loading branch information