Puneet SharmaKey-value basics
Redis stores data by key. SET writes a value, GET reads it, DEL removes it. The value can represent a session, feature flag, counter, JSON string, or cached response.
Ready. Try SET, GET, DEL, TTL, EXPIRE, PUBLISH, or SUBSCRIBE.
Run SET profile:demo Ada, then GET profile:demo.
enabledcached HTML response839201[welcome, reset-password]{redis, cache, backend}name: Ada, role: adminAda(99), Linus(87)Run a command to see exactly what changed in the simulated Redis key space.
Learn Redis Online — 8 Interactive Lessons with a Visual Key-Space Simulator
What's included
Features
About this tool
Learn Redis Visually — 8 Lessons Covering Every Core Pattern, No Server Required
Redis is one of the most widely deployed pieces of backend infrastructure in the world — used as a cache, a session store, a message broker, a rate limiter, a leaderboard engine, and a job queue. Its command set is small and fast to learn, but the mental models behind the patterns — why TTL matters, how INCR avoids race conditions, when to use a Hash versus a String, why SETNX is the foundation of distributed locking — take longer to absorb from documentation alone. The Redis Playground gives you a visual, interactive environment to practice every core Redis pattern without installing Redis, Docker, or any backend tooling.
The playground simulates Redis key-value behavior entirely in the browser. Every command you run updates the live key-space table — you can see key names, stored values, data types, and TTL countdowns all at once. Command history logs every operation with its output and a state diff showing which keys were added, changed, or deleted. Expiring keys count down to zero in real time and disappear from the table, exactly as they would in a production Redis instance.
Key-Value Basics covers the three commands you will use on every Redis project: SET writes a value, GET reads it, and DEL removes it. The lesson introduces the key naming conventions used in production systems — user:42, session:abc123, feature:new-dashboard, page:/pricing — and explains why colons are used as namespace separators.
Expiration covers SET key value EX seconds (write with TTL), TTL key (read remaining seconds), EXPIRE key seconds (add or update expiration on an existing key), and PERSIST key (remove expiration). The TTL countdown in the key table makes expiration concrete — you can see session tokens, OTP codes, and temporary locks automatically clean up without any application code.
Caching Pattern simulates the cache-aside pattern that powers most Redis deployments: check Redis first (GET), return immediately on a hit, fetch from origin on a miss, write the result to Redis with a TTL (SET key value EX 60), and serve. The lesson shows cache hit, cache miss, and expiration as three distinct states so the lifecycle is clear before you implement it in an application.
Data Types covers all four compound Redis structures. Lists (LPUSH, RPUSH, LPOP, LRANGE) are ordered sequences used for queues, activity feeds, and browser history. Sets (SADD, SMEMBERS, SCARD, SISMEMBER, SREM) store unique unordered members — perfect for tags, follower lists, and unique visitor tracking. Hashes (HSET, HGET, HGETALL, HDEL, HKEYS, HVALS) map field names to values on a single key, making them ideal for user profiles, product data, and structured objects stored efficiently without JSON serialization. Sorted Sets (ZADD, ZRANGE, ZSCORE, ZRANK) store members with a numeric score for automatic ranking — the standard approach for leaderboards, priority queues, and time-series indexing.
Atomic Counters covers INCR, INCRBY, DECR, and DECRBY. Redis processes commands on a single thread, which means INCR is guaranteed atomic — two workers calling it simultaneously always receive different integers with no application-level locking required. This makes Redis the standard choice for page view counters, vote tallies, like counts, inventory deductions, and rate limit windows (INCR + EXPIRE on a per-user-per-minute key).
Conditional Writes covers SETNX (SET if Not eXists), EXISTS, and PERSIST. SETNX returns 1 if it wrote the key (key was absent) and 0 if it did not (key already existed). This atomic behavior is the foundation of distributed locks: only the first caller in a race wins the write. Combine with EX to auto-release the lock if the worker holding it crashes. EXISTS checks presence without fetching the value — useful for checking lock state or cache warmth without the overhead of reading the full value.
Key Inspection covers the introspection commands used for debugging and operations: KEYS * and KEYS pattern (glob matching with * and ?), TYPE key (returns string, list, set, hash, or zset), RENAME key newkey (atomic rename), MSET (write multiple key-value pairs in one roundtrip), and MGET (read multiple values in one roundtrip). MSET and MGET are important for performance — reading six keys with MGET takes one network roundtrip instead of six.
Pub/Sub covers SUBSCRIBE channel, PUBLISH channel message, and UNSUBSCRIBE. Redis Pub/Sub delivers messages to all current subscribers of a channel instantly. It is used for cache invalidation signals (publish "invalidate page:/pricing" when the product changes), live notification delivery, inter-service events in microservices architectures, and lightweight realtime data without a full message queue like Kafka or RabbitMQ.
Step by step
How to Use
- 1Start with Key-Value BasicsThe first lesson covers SET, GET, and DEL — the three commands every Redis user types first. Try the pre-loaded example commands, then write your own keys using the user:id or feature:flag:name naming conventions shown in the lesson.
- 2Learn TTL expiration in the Expiration lessonRun SET otp:login 839201 EX 30 and watch the key appear in the table with a 30-second countdown. Run TTL otp:login at different times to see the remaining seconds. When the timer hits zero the key disappears — this is how Redis automatically cleans up sessions, OTP codes, and temporary locks.
- 3Understand cache hit and miss in the Caching lessonThe Caching lesson simulates the cache-aside pattern. Run GET on a key that is not in Redis — the simulator returns a miss and shows a fetch from origin. Then SET the key with an expiration and run GET again — this time it returns immediately as a hit. This is the exact flow used in production caching for API responses, database queries, and rendered pages.
- 4Try all four data typesThe Data Types lesson shows how Lists (LPUSH, LRANGE, LPOP), Sets (SADD, SMEMBERS, SCARD), Hashes (HSET, HGETALL, HKEYS), and Sorted Sets (ZADD, ZRANGE, ZSCORE) each store data differently. Run the pre-loaded command chips one at a time and watch the key-space table show the structure after each write.
- 5Build counters with INCR and INCRBYThe Atomic Counters lesson shows why INCR is special. Start with SET views:homepage 0, then call INCR multiple times. Each call atomically adds 1 — no race conditions possible. Try INCRBY views:homepage 10 to add a larger amount, and DECR / DECRBY to subtract. This pattern powers page view counters, vote tallies, and rate limit windows.
- 6Try distributed locks with SETNXRun SETNX lock:deploy worker-1 — it returns 1 (success). Run it again with a different value — it returns 0 (key already exists, write skipped). This is the foundation of distributed locking: only the first caller wins. Use EXISTS to check whether a lock is held. Use PERSIST to remove expiration from a key that should outlive its original TTL.
- 7Explore the key space with KEYS and TYPEThe Key Inspection lesson covers KEYS * (list all keys), KEYS user:* (glob pattern matching), TYPE key (returns string, list, set, hash, or zset), RENAME key newname, MSET key1 val1 key2 val2 (write multiple keys), and MGET key1 key2 (read multiple values). These commands are used for operational debugging and Redis introspection.
- 8Subscribe and publish messagesThe Pub/Sub lesson shows Redis as a lightweight message broker. Run SUBSCRIBE alerts to register interest in a channel. Run PUBLISH alerts "server deployed" to send a message. The message timeline updates immediately. This pattern is used for cache invalidation events, live notification feeds, and inter-service signaling without a full message queue.
Real-world uses
Common Use Cases
Got questions?
Frequently Asked Questions
No. The playground is a browser-based simulator that models Redis key-value behavior, TTL countdowns, Pub/Sub message flow, and command responses without connecting to any server. It is intentionally designed for learning — safe, predictable, and requires no Redis installation, account, Docker setup, or network connection.
The simulator supports the commands used across all 8 lessons: SET (with EX), GET, DEL, TTL, EXPIRE, PERSIST, INCR, INCRBY, DECR, DECRBY, SETNX, EXISTS, RENAME, KEYS (with glob patterns), TYPE, MSET, MGET, LPUSH, RPUSH, LPOP, LRANGE, SADD, SREM, SMEMBERS, SCARD, SISMEMBER, HSET, HGET, HGETALL, HDEL, HKEYS, HVALS, ZADD, ZRANGE, ZSCORE, ZRANK, SUBSCRIBE, UNSUBSCRIBE, and PUBLISH.
When you run SET key value EX 30, the key is created with a 30-second expiration. The playground's key-space table shows the remaining TTL in seconds and counts it down every second in real time. When the TTL reaches zero the key disappears from the table, exactly as it would in a real Redis instance. Run TTL key to query the remaining time at any point.
The Caching Pattern lesson demonstrates the cache-aside pattern: the application checks Redis for a key first (cache hit returns immediately), and on a miss it fetches from the origin, stores the result in Redis with an expiration time, and serves the response. This pattern is used for API response caching, database query caching, rendered HTML caching, and rate-limited data fetching.
SETNX (SET if Not eXists) writes a key only when it does not already exist and returns 1 on success or 0 if the key was already present. This atomic behavior makes it the foundation for distributed locks: the first worker to SETNX lock:job wins the lock and all others get 0, meaning they know another worker is already processing. Combine with EX to auto-release the lock if the worker crashes. The Conditional Writes lesson demonstrates this pattern.
INCR atomically increments an integer key by 1. INCRBY adds any specified amount. Because Redis processes commands sequentially on a single thread, INCR is guaranteed to be race-condition-free — two clients calling INCR simultaneously always get different values. Common uses: page view counters, vote tallies, like counts, API rate limit windows (INCR + EXPIRE), inventory tracking, and distributed sequence number generation.
The Data Types lesson covers all four compound Redis types: Lists (LPUSH, RPUSH, LPOP, LRANGE — ordered sequences used for queues, feeds, and history), Sets (SADD, SMEMBERS, SCARD, SISMEMBER, SREM — unique unordered members used for tags, friend lists, and unique visitor tracking), Hashes (HSET, HGET, HGETALL, HDEL, HKEYS, HVALS — field-value maps on one key used for user profiles and structured objects), and Sorted Sets (ZADD, ZRANGE, ZSCORE, ZRANK — members ranked by numeric score, used for leaderboards and priority queues).
No. The key space resets when the page is refreshed. This is intentional — it keeps every session predictable and removes the need to clean up state between practice runs. The playground is designed for learning concepts, not for persisting data.