Support the ongoing development of →
posted 10 years ago
Last updated 2 years ago.

Tags don't work in all cache drivers. If you're using 'file' or 'database' as cache driver you'll not be able to use tags.

Last updated 2 years ago.

Thanks for your quick answer.

Actually I'm using file cache driver. Maybe there is another way to solve my problem. I need to group the cache and after i need delete all cache from this group ;)

Last updated 2 years ago.

Well, there seems to be a macro functionality for Cache.

For example, if you wanted to store some User related data in Cache and you need to have a convenient method of invalidating all of the given user caches upon some change you could define:

// app/routes.php OR any other file that gets loaded in app/start/global.php

and then when you need to delete all user cached data you just call


This way you can more easily mimick tag-like cache data invalidation. This is not as robust as tags but can be helpful for organizing your cache.

Of course you still need to manually manage cache keys and potentially distinguish them by some id, like $user_id in above example.

Last updated 2 years ago.

i recommend you first check, if using memcached or another driver which supports tags is available on your production server. installing it locally is not hard at all. do not use array driver, it is for testing only.

the solution provided above might backfire hard. what if a user gets deleted before clearing the cache? then it would be impossible to clear the cache related to deleted user.

i'm not saying, that there are no other solutions, but i just went down this road and decided to make cache available only, when tags are present. it just got too messy without them.

Last updated 2 years ago.

what if a user gets deleted before clearing the cache?

The cache will expire, unless it's set to forever

But I totally agree with you @keevitaja. Cache tags make things way more maintainable and hugely minimize potential logic-related bugs.

Last updated 2 years ago.

Sign in to participate in this thread!


Your banner here too?

adamkrupa adamkrupa Joined 27 Feb 2014


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

Your logo here?

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

© 2024 - All rights reserved.