I understand why Cache Tags aren't allowed on the File Storage/Database cache drivers. However we develop on Windows (not by choice) where I can't/won't install Redis, and host on Linux, where we use Redis.
So, when I want to utilize cache tags, I have to do something like this:
if (Config::get('cache.driver') == 'redis')
$permissions = Cache::tags('permissions')->remember('user_' . $id, 30, function() {
return $this->Groups()->with('Permissions')->get();
});
else
$permissions = Cache::remember('user_' . $id, 30, function() {
return $this->Groups()->with('Permissions')->get();
});
And then just try to remember to do a local cache clearing when necessary.
Again, local cache driver = file and server cache driver = redis
Is there a better way to do this? I've had to do this more than once and it's not pretty.
In the least, is there a way to inline the if statement after Cache:: to adhere to DRY?
Any help is appreciated. Thanks!
(More info on the "won't" of a local Redis: We're given laptops that are already suffering in the memory department. I don't want to bog myself or my team down with any more ram-using applications than we need to. Hosting it in another server locally is also out as our network is terrabad.)
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community