There’s a new project I have been working on where I needed to make use of an in-memory cache to take some load off of the database. Memcached has been around for a long time, and it’s what I thought about using at first, but I decided to use the opportunity to learn about Redis instead. Working with Redis is fairly straightforward, and it provides very useful and helpful data types in addition to simple strings such as sets and maps.
Redis stores every object in memory, but it turns out it also dumps the contents of memory to disk by default. I needed to disable this, so after digging around, I came up with this minimal configuration which makes Redis act more like Memcached, in-memory only with no disk writes. Of course, keep in mind that if you have to restart the Redis instance, the data will be lost, so it only makes sense to use this if the data which you need to cache can be repopulated from a persistent store.
# Maximum memory
# Disable disk persistence