Support the ongoing development of Laravel.io →
posted 11 years ago
Cache

I think I dreamt something was in the docs, but in reality it isn't. I'm using a taggable cache store, Redis. I thought that if you had cached a DB query with tags, you could use dot notation to access the tags later. Let's say I have two queries:

Thing::cacheTags('things.all')->remember(60)->get();
Thing::where('active',true)->cacheTags('things.active')->remember(60)->get();

Elsewhere in the code, say in an event handler, if I ran Cache::flush('things') I would expect that it would flush queries tagged things.all and things.active or things.*. But apparently that ain't so, so now I have to do this:

Thing::cacheTags(['things','things.all'])->remember(60)->get(); 
Thing::where('active',true)->cacheTags(['things','things.all'])->remember(60)->get();

This works, but feels wrong to me. Am I doing it wrong? Is there a better way to create tagged subsets, but be able to flush the entire superset if needed?

Last updated 3 years ago.
0

Bump. Anybody?

Last updated 3 years ago.
0

My understanding is that your dot-notation assumption is incorrect and you must explicitly list the tags as you've done in your second example. Now, I say that "incorrect" in the sense that it doesn't work. I may not be thinking through all the potential drawbacks, but on the surface it seems like a pretty good convention to establish. I'd be curious to hear what others think.

Last updated 3 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

anaxamaxan anaxamaxan Joined 18 Apr 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.