-
Notifications
You must be signed in to change notification settings - Fork 11.7k
Description
Laravel Version
10.x
PHP Version
8.2
Database Driver & Version
Any
Description
It's well known that laravel tagged cache was removed from the docs a couple of months ago and it looks like a too harsh of a decision for a feature which was in the core for 10 years. So I would like to propose an alternative approach which would not require a lot of work from the devs.
I suggest to revert laravel redis tagged cache to 9.x version. It had no bugs with consistency. It always worked while flushing the tagged cache and it always returned the fresh data. Of course it had leaks, but it was not causing the application to misbehave. This feature was in laravel core for 10 years now and for most of us it was usable. So old implementation can still be used, but some caution messages should be added to the docs.
So my suggestion is to:
- Bring back the docs.
- Revert implementation for redis to 9.x
- Mention that tagged cache does not flush the tag keys and values and they might build up over time. So tagged cache should not be used with dynamically created tags. E.g. used id should not be used as a tag. Though tag cache won't be a problem if it's used with static code enums or constants as they don't scale infinitely.
- Add a requirement to always use an expiry date with the tagged cache to prevent running out of memory. So instead of using cache forever, you should cache only for one week or a month.
So old tagged cache is still usable, though developers have to be aware of the shortcomings. At current state redis tagged cache is unusable as it does not guarantee consistency so memory leaks are not even a concern if it's not working.