framework: [5.1] [5.2] Cache tags in Redis does not flush() any items cached via remember() or put()

Laravel v5.1.10 Driver: Redis with predis

This does not remove ‘test’ item: \Cache::tags(['user'])->put('test', 'value', 25); \Cache::tags(['user'])->flush();

while next code removes ‘test’ item as expected: \Cache::tags(['user'])->forever('test', 'value'); \Cache::tags(['user'])->flush();

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 47 (6 by maintainers)

Most upvoted comments

@mstephens I’ve tested my 1st example on Laravel Framework version 5.2.15. Now it works. But there is another issue with it now:

\Cache::tags(['user', 'test'])->put('test', 'value', 25);
echo \Cache::get('test'); // null
echo \Cache::tags(['user'])->get('test'); //< null
echo \Cache::tags(['test'])->get('test'); //< null
echo \Cache::tags(['test', 'user'])->get('test'); //< null
echo \Cache::tags(['user', 'test'])->get('test'); //< value

This way tags usage are very narrow because i cannot access cache entry even by its id without knowing what tags were used there. I intended to use tags for automatic caching for db querues where there are quite many situations when I need to drop all cache entries by main tag name or by main+helper tag pair. But this way i cannot even access single entry by its cache id

Hi guys, sorry to post on such an old issue, was this fixed on a newer version or is this behavior by design? I’m on 5.6.39. I saw @swayok package addressing this on github but no further discussion. https://github.com/swayok/alternative-laravel-cache I think tags are not very useful this way.

Thanks.

@mstephens I’ve tested my 1st example on Laravel Framework version 5.2.15. Now it works. But there is another issue with it now:

\Cache::tags(['user', 'test'])->put('test', 'value', 25);
echo \Cache::get('test'); // null
echo \Cache::tags(['user'])->get('test'); //< null
echo \Cache::tags(['test'])->get('test'); //< null
echo \Cache::tags(['test', 'user'])->get('test'); //< null
echo \Cache::tags(['user', 'test'])->get('test'); //< value

This way tags usage are very narrow because i cannot access cache entry even by its id without knowing what tags were used there. I intended to use tags for automatic caching for db querues where there are quite many situations when I need to drop all cache entries by main tag name or by main+helper tag pair. But this way i cannot even access single entry by its cache id

@brazenvoid got it. I think I need to switch my projects to phpredis too. Check a package in a week - I’l try to upgrade it until then

Now with phpredis, the above package also doesn’t work, making it even more of a reason to fix this. Its obvious that Laravel team is uninterested in fixing this and is waiting for someone to fix it for them. In the meanwhile their users get frustrated profiling their systems, finally stumbling on this closed issue and only by reading it thoroughly will they get to know the known issues.

There should have been a known issues section mentioning this as the documentation clearly says otherwise. My team would not have used this forsaken tagged cache, profiled our caching system to discover how broken it is, and now they even have to remake everything to be compatible with regular key value pairs…