0
0
Redisquery~15 mins

SADD and SREM for membership in Redis - Mini Project: Build & Apply

Choose your learning style9 modes available
Manage a Redis Set with SADD and SREM
📖 Scenario: You are managing a Redis database for a small online bookstore. You want to keep track of the unique genres of books currently available in the store using a Redis set.
🎯 Goal: Build a Redis set called book_genres that stores genres using SADD to add genres and SREM to remove genres when they are no longer available.
📋 What You'll Learn
Create a Redis set named book_genres with initial genres.
Add a configuration variable for a genre to remove.
Use SADD commands to add genres to the set.
Use SREM command to remove a specific genre from the set.
💡 Why This Matters
🌍 Real World
Managing unique collections like book genres, user tags, or product categories efficiently in Redis.
💼 Career
Understanding Redis set commands like SADD and SREM is essential for backend developers working with caching, session management, or real-time data.
Progress0 / 4 steps
1
Create the initial Redis set with genres
Use the SADD command to create a Redis set called book_genres and add these exact genres: "Fiction", "Science", "History".
Redis
Need a hint?

Remember, SADD adds one or more members to a set. Use the exact set name book_genres and genres.

2
Set the genre to remove
Create a Redis key called genre_to_remove and set it to the string "Science".
Redis
Need a hint?

Use the SET command to create a key genre_to_remove with the value Science.

3
Add more genres to the set
Use the SADD command to add these genres to the book_genres set: "Biography" and "Fantasy".
Redis
Need a hint?

Use SADD again with the same set name and the new genres.

4
Remove the genre from the set
Use the SREM command to remove Science from the book_genres set.
Redis
Need a hint?

Use SREM with the set name and the genre value to remove it from the set.