I have an application that makes use of frequently updated lists. So for example, every person that clicks a button, gets added to a unique list associated to that button. Then we’ll want to display these lists, by button, in descending order and with a limit.
We’ve been doing this using MySQL and Memcache. The problem is this does not work well.
What I plan to do is use Redis lists. Each button will hold a unique key in redis, each user will be added to the key using LPUSH If we want to get the latest 10, we can use LRANGE 0 10
Now, eventually these buttons will ‘expire’ and no longer be actively added to or clicked, however, we’ll want historic data. The idea is once these expire, we will get the data from Redis and populate it to MongoDB. Any queries on the historic data, will be against the MongoDB.
Would anyone suggest against this solution? Does it “make sense” to do it this way?
Thank you!
This solution makes sense, I do something similar in my app.
One thing to note, though:
Do you allow duplicate users in that list? If yes, use lists. If not, you might want to couple it with set (for unique checks), but it’ll cost you some RAM.