Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On update, cache flush bug #209

Open
shixue opened this issue Jan 24, 2024 · 2 comments
Open

On update, cache flush bug #209

shixue opened this issue Jan 24, 2024 · 2 comments

Comments

@shixue
Copy link

shixue commented Jan 24, 2024

The cause of this bug (issues #97) :
QueryCacheable:

public function getCacheTagsToInvalidateOnUpdate($relation = null, $pivotedModels = null): array
{
    return $this->getCacheBaseTags();
}

Example:

User::cacheTags(['user:29'])->find(29);
$userId = 28;
$model = User::cacheTags(['user:' . $userId])->find($userId);
//...
$model->update(['ip' => $ip]);

When specifying the cacheTags getCacheTagsToInvalidateOnUpdate() method should return it.
All that is returned so far is getCacheBaseTags(), the cached updated tags are static::class, not the specified tags.
Just like the flushQueryCache() method, use it if tags are specified, otherwise use the getCacheBaseTags() method.

@shixue
Copy link
Author

shixue commented Jan 24, 2024

Tags can be added to the Model after the queried.
getCacheTagsToInvalidateOnUpdate() method to obtain the Model of the specified Tags, if the Model exists to specify Tags.

@shixue shixue changed the title On update, cache refresh bug On update, cache flush bug Jan 25, 2024
@stale stale bot added the wontfix This will not be worked on label Mar 17, 2024
@kevinlau-drewberry
Copy link

@shixue would you mind explaining how to add tags after a query is made?

@stale stale bot removed the wontfix This will not be worked on label Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants