renoki-co/laravel-eloquent-query-cache

Using "flushQueryCache" with User Model

devajmeireles opened this issue · 2 comments

After performing some tests using the flushQueryCache method I realized that it is not possible to define:

    protected function getCacheBaseTags(): array
    {
        return [
            Auth::check() ?
                'user_' . Auth::user()->id
                : (string) static::class,
        ];
    }

... for the user model! Why? When I set this, the application behaves strangely. (Laravel Sail), seeming not to work anymore.

The purpose of the tests is to clear the cache associated with a user, not everyone (user table).

I assume you want to use the base tags with the per-user tag. 😅

protected function getCacheBaseTags(): array
{
    if (! Auth::check()) {
        return parent::getCacheBaseTags();
    }

    return array_merge(parent::getcacheBaseTags(), [
        'user_' . Auth::user()->id,
    ];
}
stale commented

This issue has been automatically closed because it has not had any recent activity. 😨