What Redis is and why apps love it. Save keys, read them, delete them, and name them like a pro.
Your first keyTry itSET key value saves, GET key reads. Redis answers every command.
Keys with a patternExerciseName keys like object:id:field, and put text with spaces in quotes. Values are always stored as text.
Delete a cartExerciseDEL deletes keys and EXISTS checks if a key is there (1 or 0).
The motto that brokeDebugSpaces separate values in Redis. Text with spaces goes in quotes.
Quick checkQuizSET, GET, DEL and EXISTS, key names with colons, and quotes for text with spaces.
2. Counters and time
Count visits and coins in one safe step, and make keys that delete themselves after a while.
Count the visitorsExerciseINCR adds 1 and INCRBY adds any number, safely, even with many users at once.
Spend and earnExerciseDECRBY and DECR take away, INCRBY and INCR add.
A code that expiresExerciseEX seconds makes a key expire, and TTL tells how long it has left.
A flash saleExerciseWhen the TTL runs out, Redis deletes the key by itself.
Ten is not a numberDebugINCR, INCRBY and DECRBY need values written as whole numbers with digits.
Quick checkQuizINCR/INCRBY/DECRBY, EX and TTL, and keys that delete themselves.
3. Lists
Ordered values: to-do lists, job queues and "the latest 10" lists.
A to-do listExerciseRPUSH/LPUSH add to the end/start of a list, and LRANGE key 0 -1 reads all of it.
A queue of jobsExerciseRPUSH + LPOP make a queue: first in, first out. LLEN counts what is waiting.
Only the latest 3ExerciseLPUSH + LTRIM key 0 n keeps a list of the newest items, at a fixed size.
GET on a listDebugEach type has its own commands: GET for strings, LRANGE for lists. TYPE key tells you which one it is.
Quick checkQuizRPUSH, LPUSH, LPOP, LRANGE, LLEN and LTRIM: queues and "latest" lists.
4. Hashes
One key, many fields: user profiles and objects, and counters inside them.
A user in one keyExerciseA hash holds fields: HSET sets them, HGET reads one, HGETALL reads all.
Coins inside the profileExerciseHINCRBY adds to a number field of a hash.
Remove a fieldExerciseHDEL removes a field, HEXISTS checks if one is there.
A field without a valueDebugHSET takes field-value pairs: every field needs a value right after it.
Quick checkQuizHSET, HGET, HGETALL, HINCRBY, HDEL and HEXISTS.
5. Sets
Unique values: tags, who is online, and friends in common.
Unique tagsExerciseA set keeps each value once. SADD, SMEMBERS, SCARD.
Who is online?ExerciseSISMEMBER checks if a value is in a set: 1 or 0.
Friends in commonExerciseSINTER (in both), SUNION (in either) and SDIFF (in the first only) combine sets.
LRANGE on a setDebugSets are read with SMEMBERS, not LRANGE: they have no positions.
Quick checkQuizSADD, SMEMBERS, SCARD, SISMEMBER, SINTER, SUNION and SDIFF.
6. Sorted sets
Members with scores, always in order: leaderboards, ranks and score ranges.
A leaderboardExerciseZADD adds members with scores; ZREVRANGE ... WITHSCORES lists them from the top.
A new leaderExerciseZINCRBY adds to a score, ZREVRANK gives the place from the top (0 = first).
Players in a rangeExerciseZRANGEBYSCORE and ZCOUNT work on a range of scores.
The upside-down top 3DebugZRANGE starts at the lowest score, ZREVRANGE at the highest.
Quick checkQuizZADD, ZINCRBY, ZREVRANGE, ZREVRANK, ZRANGEBYSCORE and ZCOUNT.
7. Redis in real apps
The patterns behind real products: caches, rate limiters, login sessions and transactions.
A cacheExerciseCache: GET first; on (nil), compute and SET with EX; the next GET is instant.
A rate limiterExerciseA rate limiter: INCR per request, EXPIRE on the first one, and block above the limit.
A login sessionExerciseSessions: a hash with the details plus EXPIRE, so they clean themselves up.
Send coins safelyExerciseMULTI queues commands and EXEC runs them together, with nothing in between.
The cache that never refreshesDebugCache keys always need an expiry, or they serve old data forever.
Quick checkQuizCaches, rate limiters, sessions and transactions.
8. Redis exam
Ten questions about everything in this course. Pass with 8 right answers.
The Redis examExamStrings, counters and expiry, lists, hashes, sets, sorted sets, and real-app patterns.
9. Final project
Design the data of an online game in Redis: profiles, a leaderboard, inventories, sessions and counters. Then send it for review.
A game backendFinal projectChoosing the right type for each job: that is designing with Redis.
How the course works
You learn by doing: each lesson explains one idea, then you write real code in the editor and see the result right away. The first lesson is free to try without an account; sign up to save your progress and continue.
Try it
Change working code and see the result immediately.
Exercise
Complete a task. A checklist confirms each requirement as you type.
Debug
Fix code that is broken on purpose, and learn why it failed.