Skip to content

It isn't possible to access an entry tagged with multiple tags by providing just one of this tags [Cache Tags] #25234

@sgasser

Description

@sgasser
  • Laravel Version: 5.6.29
  • PHP Version: 7.2

https://laravel.com/docs/5.6/cache#cache-tags

Description:

It is possible to invalidate all entries tagged with multiple tags by providing just one of this tags, but to access an entry you have to pass all tags in the exact order. It would be great if you could access all entries tagged with multiple tags by providing just one of this tags.


Example for my case:

I'm creating a package to cache eloquent queries.

Storing

List of authors
Cache::tags(['author-1', 'author-2', 'author-3', 'author-all'])->put('List'.$checksum, $authorList, $minutes);

Invalidate

Invalidate author (for example update author)
Cache::tags(['author-1'])->flush();
Invalidate list (for exampe I added a new author)
Cache::tags(['author-all'])->flush();

Accessing

To get the list I have to know all tags:
Cache::tags(['author-1', 'author-2', 'author-3', 'author-all'])->get('List'.$checksum);

Better solution

Cache::tags(['author-all'])->get('List'.$checksum);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions