| ▲ | kijin 3 hours ago | ||||||||||||||||
Redis works great as a cache, but there are a few things you need to do in order to use it reliably as a cache. 1) Wrap your client library so that it's impossible to store anything without an expiry date. You don't want 6-months-old data suddenly coming up in your app! 2) Either turn off persistence, or use a separate database for the cache. In other words, don't mix volatile data with stuff you actually care about. 3) Set up a reasonable maxmemory value with an appropriate maxmemory-policy, so that Redis doesn't eat up all your RAM. 4) Resist the urge to use complex data structures. If you try to update a single field on an expired hash, you will end up with an incomplete object. If you don't want all that hassle, then yes, Memcached probably works better out of the box. | |||||||||||||||||
| ▲ | dvt 2 hours ago | parent [-] | ||||||||||||||||
> 1) Wrap your client library so that it's impossible to store anything without an expiry date. You don't want 6-months-old data suddenly coming up in your app! No need for this client-side complexity, as you should be using `allkeys-lru`. FWIW, should likely be doing this anyway, as (generally speaking) all data stored in Redis is usually regarded as volatile because of what Redis actually is. | |||||||||||||||||
| |||||||||||||||||