Using Cache::flexible in with redis #52858
-
Cache::flexible is supposed to get the stale data from the cache and return it to the user while recalculating and setting the cache again in the background. Now with redis: So my question here Thanks for all 💥 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Well, reading the code under the hood, it doesn't give a timestamp to redis. As far as redis, or any other driver is concerned, it is a cache item that is to stay forever. there is a second cache item that contains the ttl. if that is reached, it will renew the data. depending on the lock configuration, which in my humble opinion is quite complex. I don't understand why or what that is doing. but bottom line is, it doesn't rely on redis ttl at all. |
Beta Was this translation helpful? Give feedback.
ah, looking again at the code, this time rearranging it so I can actually read this, it is indeed putting in a ttl.
ttl is an array here, so you have to set the second farther away into the future thant the first one. then it might work. This is what is called the grace period. Between those two periods the old cache is still returned while the request for creating new data is being deferred so that next request can have the new data.
imho way to complex and un-laravel-like method imho.