I am using Laravel 5.2 Cache with memcached driver.
Was trying to implement the Cache::tags into my project but doesn't seems to be working.
But it works well when I am using
Cache::put('user_1', $user, 600);
Here is my code
Cache::tags('user')->put('user_1', $user, 600);
and I've tried using
Cache::tags(['user'])->put('user_1', $user, 600);
as it mentioned in the API docs saying it supported array|mixed $names
Not sure if anyone out there having the similar issue like me?
This got me quite confused as well. When using cache tags with Laravel, to fetch the stored data from the cache, you need to specify the used tag(s).
E.g. when storing data like this:
Cache::tags('user')->put('user_1', $user, 600);
This won't fetch the data back:
Cache::get('user_1');
But this will:
Cache::tags('user')->get('user_1');
The behaviour is still the same with Laravel 5.4 (current version at the time of writing).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With