0
0
Redisquery~15 mins

SUNIONSTORE for storing results in Redis - Mini Project: Build & Apply

Choose your learning style9 modes available
Using SUNIONSTORE to Combine Sets in Redis
📖 Scenario: You are managing a Redis database for a social app. You have two sets representing users who liked two different posts. You want to create a new set that stores all users who liked either post.
🎯 Goal: Build a Redis command sequence that creates two sets with exact user IDs, then use SUNIONSTORE to combine these sets into a new set storing all unique users who liked either post.
📋 What You'll Learn
Create a Redis set called post1_likes with members user1, user2, and user3
Create a Redis set called post2_likes with members user3, user4, and user5
Use SUNIONSTORE to store the union of post1_likes and post2_likes into a new set called all_likes
Verify the commands use the exact set names and members as specified
💡 Why This Matters
🌍 Real World
Social media apps often track user interactions like likes or follows using sets in Redis for fast membership checks and combining user groups.
💼 Career
Understanding Redis set operations like SUNIONSTORE is important for backend developers working with caching, real-time analytics, and user data aggregation.
Progress0 / 4 steps
1
Create the first set post1_likes
Use the Redis command SADD to create a set called post1_likes with members user1, user2, and user3.
Redis
Need a hint?

Use SADD followed by the set name and the members separated by spaces.

2
Create the second set post2_likes
Use the Redis command SADD to create a set called post2_likes with members user3, user4, and user5.
Redis
Need a hint?

Remember to use the exact set name post2_likes and members.

3
Use SUNIONSTORE to combine the sets
Use the Redis command SUNIONSTORE to create a new set called all_likes that stores the union of post1_likes and post2_likes.
Redis
Need a hint?

SUNIONSTORE takes the destination set name first, then the source sets.

4
Verify the union set all_likes
Use the Redis command SMEMBERS to check the members of the set all_likes to confirm it contains all unique users from both sets.
Redis
Need a hint?

SMEMBERS returns all members of a set.