CacheQuery icon indicating copy to clipboard operation
CacheQuery copied to clipboard

[X.x] Add support for cache tags

Open binaryfire opened this issue 1 year ago • 3 comments

Please check these requirements

  • [X] This feature helps everyone using this package
  • [X] It's feasible and maintainable
  • [X] It's non breaking
  • [X] I issued a PR with the implementation (optional)

Description

Would it be possible to add support for optionally using cache tags? So we can do things like:

Article::latest('published_at')->with('drafts')->take(5)->cache(key: 'latest_articles' tag: 'tenant_1')->get();

Cache::tags('tenant_1')->flush();

etc.

Code sample

See above :)

binaryfire avatar Jan 26 '24 22:01 binaryfire

I think it's feasible, as long the cache stores is compatible with tags.

DarkGhostHunter avatar Feb 27 '24 17:02 DarkGhostHunter

Okay, I think I have some kind of implementation, but it will be with a giant warning because the store must be taggable, and the default cache is file which isn't.

Also, Laravel already discourages using tagging values.

DarkGhostHunter avatar Mar 15 '24 06:03 DarkGhostHunter

Awesome! Look forward to testing it,

binaryfire avatar Mar 15 '24 06:03 binaryfire

No longer in the works, as Laravel doesn't document it probably to discourage it.

You can still use the Cache directly to retrieve your database results.

DarkGhostHunter avatar Jan 28 '25 19:01 DarkGhostHunter