What is a cache vs a database? You can use mysql as a cache. Most people would call it a database.
Really this article is dumb. I think almost never would you need to choose redis vs mongo.
Redis is a weird and hard to describe product. For example you can use it as a queue over rabbitmq with celery. Or a cache with all kinds of things. But it does more. And an empty instance runs in like 3mb of ram and handles thousands of connections.
At my last company, we used redis both for celery as a queue, and a cache for values we needed to call often and retrieve quickly. We ALSO used Mongo, but moreso as a store for larger documents that were called less frequently. I think it's not fair to compare them directly together, they are each useful in their own specific cases.
The way I look at Redis is a service that helps to off-load main db. Obvious example is how people use it as a cache. But it has other use, such as:
- Leaderboard: Redis shines when we need to store ranking data.
- Geo Query: Instead of query geo spatial index directly from MongoDB. I use Redis and feed the id back into MongoDB
- Track Occurence Of Event: Let's say we need to keep track state of an user
- Set of data
In other words, I treat Redis as a network/distributed data structure, which I can implement in the main db, but will require heavy read/write.
Redis is great when used as a persistent cache for short-lived + no value data, or data that can be reproduced from another source. If your data, or queued items, have value then find a better tool.
But if you're foolish enough to use it as a database... lol.
20 comments
[ 4.1 ms ] story [ 62.7 ms ] threadReally this article is dumb. I think almost never would you need to choose redis vs mongo.
Redis is a weird and hard to describe product. For example you can use it as a queue over rabbitmq with celery. Or a cache with all kinds of things. But it does more. And an empty instance runs in like 3mb of ram and handles thousands of connections.
You can store data in text files too.
- Leaderboard: Redis shines when we need to store ranking data. - Geo Query: Instead of query geo spatial index directly from MongoDB. I use Redis and feed the id back into MongoDB - Track Occurence Of Event: Let's say we need to keep track state of an user - Set of data
In other words, I treat Redis as a network/distributed data structure, which I can implement in the main db, but will require heavy read/write.
But if you're foolish enough to use it as a database... lol.