Skip to content
Tutorials Center
My learning

Topics

Redis Tutorial

Learn Redis step by step: 42 lessons in 10 chapters with examples, quizzes, diagrams and projects.

Start learning →

of lessons completed

Getting Started

  1. 1 What Is Redis? Learn what Redis is, why it is so fast, how its single-threaded command loop works, what it is used for, and how it differs from databases and Memcached.
  2. 2 Installing Redis and Using redis-cli Install Redis with Docker, Linux, macOS or WSL, then learn redis-cli: PING, key naming, SELECT databases, INFO, MONITOR and the RESP wire protocol.

Core Data Types

  1. 3 Strings and Counters Learn Redis strings: SET options (NX, XX, EX, GET), APPEND, GETRANGE, atomic INCR counters, MSET and MGET, binary safety and size limits, with live examples.
  2. 4 Keys, Expiry and TTL Learn Redis key expiry: EXPIRE, TTL, PERSIST, lazy and active expiry, SCAN versus KEYS, TYPE, RENAME, DEL versus UNLINK and key naming conventions.
  3. 5 Lists Redis lists: LPUSH and RPUSH, LPOP and RPOP, LRANGE, LTRIM, LINSERT, blocking BLPOP, LMOVE, capped lists for recent items and the O(N) pitfalls.
  4. 6 Hashes Learn Redis hashes: HSET, HGET, HGETALL, HINCRBY, HEXISTS, HSCAN, field-level expiry (HEXPIRE), hashes versus JSON strings, and why small hashes save memory.
  5. 7 Sets Learn Redis sets: SADD, SREM, SISMEMBER, SINTER, SUNION, SDIFF, SPOP, SRANDMEMBER and SSCAN, with tags and unique visitors, using a live emulator.
  6. 8 Sorted Sets Learn Redis sorted sets: ZADD, ZRANGE by index, score and lex, ZRANK, ZINCRBY, ZUNIONSTORE, leaderboards and the skip list behind them, with live demos.
  7. 9 Streams Learn Redis Streams: XADD and entry IDs, XRANGE, XREAD, consumer groups with XREADGROUP and XACK, pending entries, XTRIM, and streams vs lists and pub/sub.

Specialized Data Types

  1. 10 Bitmaps and Bitfields Learn Redis bitmaps and bitfields: SETBIT, GETBIT, BITCOUNT, BITPOS, BITOP and BITFIELD for daily active users and packed counters, with a live emulator.
  2. 11 HyperLogLog and Probabilistic Structures Learn Redis HyperLogLog (PFADD, PFCOUNT, PFMERGE), Bloom filters and Count-Min Sketch: approximate counting, error rates and memory use, with live JavaScript sketches.
  3. 12 Geospatial Indexes Learn Redis geospatial indexes: GEOADD, GEOPOS, GEODIST, GEOHASH and GEOSEARCH, how geohash scores live in sorted sets, and nearby search, with live demos.
  4. 13 Choosing the Right Data Type Learn to model data in Redis by access pattern: pick between strings, hashes, lists, sets and sorted sets, design keys, and avoid KEYS and huge keys.

Working with Redis

  1. 14 Transactions: MULTI, EXEC and WATCH Learn Redis transactions: MULTI, EXEC and DISCARD, why there is no rollback, how queue errors differ from run errors, and WATCH check-and-set locking.
  2. 15 Pipelining and Pub/Sub Learn Redis pipelining to cut round trips, and Pub/Sub with PUBLISH, SUBSCRIBE and PSUBSCRIBE, including at-most-once delivery and when to use streams.
  3. 16 Lua Scripting and Functions Learn Redis Lua scripting: EVAL and EVALSHA, KEYS versus ARGV, atomic execution, SCRIPT LOAD, Redis Functions with FCALL, and common script pitfalls.
  4. 17 Using Redis from Node.js, Python, PHP and Java Connect to Redis from Node.js, Python, PHP and Java: popular drivers, connection pooling, timeouts, retries, error handling and value serialization.
  5. 18 Redis with Spring Boot, RedisTemplate and @Cacheable Use Redis from Spring Boot: Spring Data Redis, RedisTemplate and serializers, @Cacheable, @CachePut and @CacheEvict, cache TTLs, @RedisHash repositories and pub/sub.
  6. 19 Redis Caching in Django and Flask Cache with Redis in Django and Flask: the CACHES setting, per-view and low-level cache API, sessions in Redis, Flask-Caching and hand-written cache-aside with invalidation.

Caching and Application Patterns

  1. 20 Caching Patterns Learn Redis caching patterns: cache-aside, read-through, write-through and write-behind, how to choose TTLs, and how to design versioned cache keys.
  2. 21 Cache Invalidation and Stampedes Learn how to invalidate Redis caches safely and stop cache stampedes with locks, early refresh, stale-while-revalidate, negative caching and hot-key tactics.
  3. 22 Memory Limits and Eviction Learn how Redis maxmemory works, what each eviction policy does (LRU, LFU, volatile, allkeys, noeviction), approximated LRU, MEMORY USAGE and encodings.
  4. 23 Sessions and Rate Limiting Store user sessions in Redis hashes with TTLs and build rate limiters: fixed window, sliding window log, token bucket and leaky bucket, made atomic with Lua.
  5. 24 Queues, Distributed Locks and Leaderboards Build a reliable Redis queue with LMOVE, delayed jobs with sorted sets, safe SET NX PX locks with fencing tokens, and real-time leaderboards, with demos.
  6. 25 Redis Stack: JSON, Search and Vectors Store documents with Redis JSON, query them with secondary indexes and full-text search, and use vector similarity for AI caching. Includes runnable stand-ins.
  7. 26 Redis in System Design, Distributed Cache and Session Store Design with Redis: a distributed cache layer, multi-level caching with a near cache, a central session store, and back-of-the-envelope capacity and throughput estimates.

Persistence and Durability

  1. 27 Persistence: RDB and AOF Understand Redis persistence: RDB snapshots, BGSAVE and save points, the append-only file, fsync policies, AOF rewrite, multi-part AOF, hybrid mode and backups.

High Availability and Scaling

  1. 28 Replication Learn Redis replication: leader and replicas, REPLICAOF, full and partial resync, the replication backlog, stale reads on replicas and the WAIT command, with demos.
  2. 29 High Availability with Sentinel Learn Redis Sentinel: monitoring, SDOWN and ODOWN, quorum versus majority, automatic failover, how clients find the master and how split-brain is limited.
  3. 30 Redis Cluster and Sharding Learn Redis Cluster: 16384 hash slots, CRC16 key hashing, hash tags, MOVED and ASK redirects, multi-key limits, resharding and client-side sharding.

Operations, Security and Performance

  1. 31 Securing Redis Secure Redis the right way: bind and protected mode, ACL users and permissions, requirepass, TLS, dangerous commands, exposed-server incidents and safe defaults.
  2. 32 Performance and Latency Understand Redis speed: the single-threaded command loop, I/O threads, slow commands, SLOWLOG and LATENCY, big and hot keys, compact encodings and redis-benchmark.
  3. 33 Monitoring and Troubleshooting Monitor Redis with INFO: hit rate, evictions, connected clients, memory fragmentation, replication lag, CLIENT LIST, OOM and other errors, plus Prometheus.
  4. 34 Running Redis in Production Run Redis in production: Docker Compose and Kubernetes basics, managed services, Linux settings, backups, rolling upgrades, capacity planning and Valkey.

Projects

  1. 35 Project: URL Shortener with Click Stats Build a URL shortener on Redis: INCR ids, expiring links with SET NX EX, hashes for stats, HyperLogLog unique visitors and a sorted-set top list.
  2. 36 Project: Chat Rooms with Presence Build chat rooms on Redis: pub/sub for live messages, streams for history, and sets plus expiring heartbeat keys for who is online, with live demos.
  3. 37 Project: A Reliable Job Queue Build a job queue on Redis with producers and workers, delayed jobs, retries with exponential backoff, a visibility timeout and a dead-letter list.
  4. 38 Project: Cached API with Rate Limiting Put Redis in front of a slow API: cache-aside with TTL, a lock that stops cache stampedes, a per-user token bucket, and hit-rate metrics, with live demos.
  5. 39 Project: Game Leaderboard Service Build a leaderboard on Redis sorted sets: top lists, around-me rank windows, daily and weekly boards with ZUNIONSTORE, TTL cleanup and tie-breaking.

Practice and Review

  1. 40 Practice Exercises with Solutions Twelve graded Redis exercises on strings, expiry, lists, hashes, sets, sorted sets, transactions, rate limiting, caching and locks, with runnable code and solutions.
  2. 41 Redis Interview Questions 30 common Redis interview questions with concise answers: single-threaded speed, data types, persistence, eviction, replication, cluster, locks and pitfalls.
  3. 42 Redis Cheat Sheet A one-page Redis cheat sheet: commands by data type, expiry, transactions, persistence, replication, cluster, config, ACL and safety reminders in compact tables.