0
0
Redisquery~30 mins

Redis data model (key-value) - Mini Project: Build & Apply

Choose your learning style9 modes available
Redis data model (key-value)
📖 Scenario: You are building a user profile system with Redis. You need to store user data, manage sessions with expiration, and use the right data types for different access patterns.
🎯 Goal: Store user profiles using hashes, manage sessions with TTL, and use lists for activity tracking.
📋 What You'll Learn
Store a user profile using a Redis hash
Create a session key with expiration
Track recent user activity with a list
Retrieve all data back to verify
💡 Why This Matters
🌍 Real World
Redis key-value patterns are the foundation of session management, caching, and real-time data systems at companies like Twitter, Instagram, and Stack Overflow.
💼 Career
Every backend developer needs to understand Redis data types to choose the right structure for caching, sessions, queues, and real-time features.
Progress0 / 4 steps
1
Store a user profile with HSET
Use HSET to store a user profile at key user:42 with fields: name set to "Alice", email set to "alice@example.com", and age set to "30".
Redis
Need a hint?

HSET key field value field value — sets multiple fields in one command.

2
Create a session with expiration
Use SET with the EX option to create a session key session:abc123 with value "user:42" that expires in 3600 seconds.
Redis
Need a hint?

SET key value EX seconds — sets the key with an automatic expiration.

3
Track activity with a list
Use LPUSH to add three activities to the key activity:user:42: "login", "view_profile", and "update_email" in that order.
Redis
Need a hint?

LPUSH pushes elements to the left (head) of the list. Multiple values can be pushed in one command.

4
Retrieve all data
Write three commands: HGETALL user:42 to get the full profile, TTL session:abc123 to check session remaining time, and LRANGE activity:user:42 0 -1 to get all activities.
Redis
Need a hint?

HGETALL returns all fields and values. TTL returns seconds remaining. LRANGE 0 -1 returns the entire list.