This use case will focus on using Redis for the social aspects of a community website. Redis is a key-value store, which operates faster and more smoothly than a traditional relational database like MySQL. Redis stores data in a flexible structure similar to a dictionary or hash, which makes it an excellent choice for fast-paced scenarios like social applications.
- Introduction to Redis
- Installing Redis on a IONOS Linux Servidor Cloud
Use Case: Social Website
For this use case, the user is building a website for a hobby community which will have several social components. The user hopes to build communication between hobbyists, so that visitors can ask questions, make friends, and learn new skills.
Scenario 1: Message Feed
Each website visitor can set up an account with a personal profile page. In this scenario, the site designer wants to implement a Twitter-style message feed which website users can use to post updates, re-post messages from other users, respond to other users' posts, and participate in message threads.
Redis's in-memory storage engine makes it an excellent choice for a message queue platform of this type. In fact, the official Redis site includes a tutorial on how to design and implement a Twitter clone in Redis.
Scenario 2: Leaderboard
The site designer wants to implement monthly contests for its visitors. She plans to keep a leaderboard prominently displayed on the main page of the website, to help encourage participation.
The Redis implementation of sorted sets make it a perfect fit for easily and quickly implementing a leaderboard of this type.
Scenario 3: User Notifications
In this scenario, the site designer wishes to implement a system of user notifications. Users will be able to subscribe to the notification feed of another user, so that they receive notifications any time that user posts a new article or comment.
This functionality in Redis is called "Pub/Sub." It includes the ability to publish messages, subscribe, and unsubscribe to message feeds. Pub/Sub also allows a great deal of subscription customization, to ensure that users only see messages which are of interest to them.