memcache vs redis of nodejs for chatting app

聊天程序的Nodejs Memcache VS redis

问题 (Question)

what's the difference between redis & memcached, which one is best to use for chat application, any suggestions


最佳答案 (Best Answer)

main difference is

memcached is cache, Redis is IMDB (In memory database).

it means, in memcached, data is full , it will be removed by eviction logic like (LRU etc). and if server is down, the whole data will be lost.

but in case of Redis, it persist the data to file, so even if it has been crashed, it can recover data.

in addition there are so many difference. Only same thing is those are memory based K/V store.

Redis can support clustering and Master/slave replication, Data model also different etc.





此外还有很多不同的。只有相同的事情是那些基于K / V存储记忆。


答案 (Answer) 2

As Terry Cho said, the main difference is the method of storing the data.

Memcaching stores the data in the RAM on each server, or in the RAM of your memcache server. Redis stores the data in an in memory database, and pretty much every operation in Redis has an operational complexity of O(1) which makes it extremely fast.

Personally, I use Redis for caching as I can share the same cache between a cluster of servers and set up data expiration automatically which still maintaining the minimal operational complexity for retrieving the data.

For a chat application, Redis would work better as you likely want the data to persis if your server restarts. I would use a database like MongoDB or PostgreSQL for the best performance of a persistent chat application though.