3 ms·
> if for some reason the memory cache diverges from the true count, we just wipe out the memory cache and the app takes care of regenerating it automatically W
by antirez 16y ago
> if for some reason the memory cache diverges from the true count, we just wipe out the memory cache and the app takes care of regenerating it automatically
Warning, this is a myth: once you starte relying on caching to serve your amount of traffic, flushing the cache will have the result of taking the site down. This is why persistence is an absolute requirement of a serious caching server IMHO. With Redis when things may be in desync it's better to selectively remove entries with (RANDOMKEY+DEL) at a rate that the system is able to handle.
Also given that you are using Redis that has atomic increments, why not going the extra mile and issuing INCR/DECR operations when something is added/removed?
- kylebragger 16y agoI should have been more specific--technically the cache would be wiped for a specific post, never for the entire db of posts. But you're totally right about the persistence --that's why something like redis made sense to me. Useful tip about randomkey and del, thank you. I def. could switch it over to an incr/decr setup. Maybe I'll do that tonight.