Yesterday I was investigating Redis as a potential key-value storage. In particular, it’s potential for session storage. I thought I should share some of my findings here.
An application I’m currently helping to maintain uses Memcached to store session data. This is bad for at least 2 reasons:
- Memcached data is not persisted to disk, leading to potential of closing sessions if the server is having issues,
- Expired keys aren’t removed automatically; they only get deleted on the next retrieval, meaning that most of the time, sessions never get deleted, because the user stops responding, and their sessions remain stale until the next instance restart
Redis was seen as a good alternative. It supports key expiration that automatically deletes keys. It also saves data to disk, preventing data loss.