Redis Usecase: Find out who is Online
If you are a Facebook user you know there is a chat application (I confess I haven’t used it, but I know it is there). With such an application an important question to answer is: “which of my friends are online now”. While I’m pretty sure that Facebook implementation is different and not based on Redis, I have found two articles describing two different solutions for this problem based on Redis.
First one, coming from Luke Melia: ☞ Who’s Online? is using Redis support for SETs and set operations to solve it.
The second approach, coming from Rick Olson: ☞ Track user locations with Node.js and Redis, proposes a different approach based on usage of “smart keys” and key expiration support in Redis.
Not sure if the complete code for the first solution is available, but the relevant code is included in the article. As for the second, you can find the source code on ☞ GitHub.
Last, I should probably mention that in the case of a web application solving this problem is a bit easier than for classical desktop IMs., but these Redis usecases are a great example for how you can use Redis. Another emerging usecase is session storage with NoSQL. And you’ll find even more in this great list of Redis usecases.