Stage 3 · Build
Caching, Queues & Background Jobs
Redis Basics
Use Redis strings, hashes, TTLs, pipelining, go-redis clients, and connection management.
What Is Redis
Redis is an in-memory data store used for caching, session storage, rate limiting, and message queues. It supports multiple data types, atomic operations, and pub/sub messaging. It is the most popular choice for backend caching.
Data Types
| Type | Use Case | Commands |
|---|---|---|
| String | Simple values, counters, locks | GET, SET, INCR, APPEND |
| Hash | Object storage, user sessions | HGET, HSET, HGETALL |
| List | Message queues, recent items | LPUSH, RPUSH, LPOP, LRANGE |
| Set | Unique items, tags, followers | SADD, SMEMBERS, SINTER |
| Sorted Set | Leaderboards, time-series | ZADD, ZRANGE, ZRANK |
go-redis Client
Pipelining
Pipelining sends multiple commands in a single network round-trip. This dramatically reduces latency when executing many Redis operations.
TTL and Expiry
Connection Management
Redis connections are lightweight but not free. go-redis pools connections automatically. Set PoolSize to 2x your expected concurrency. Monitor idle connections to avoid stale connections.
Mark this lesson complete to store local progress and unlock a cleaner resume path the next time you visit.