Infrastructure: Redis introduction
This course introduces Redis, a separate network service that holds data in RAM as named data structures. It covers strings and atomic counters, lists and sets, hashes and sorted sets, memory limits with maxmemory and eviction policies, and pub/sub with its at-most-once delivery. Each Redis claim is checked against Redis's documentation. The lessons also compare Redis with this app, which runs no Redis and uses Postgres-backed Solid Cache, Solid Queue and Solid Cable for caching, background jobs and Action Cable broadcasts.
What you'll learn
- ✓Redis strings with SET, GET, MSET, MGET and atomic INCR
- ✓Lists for queues, with LPUSH, RPOP and blocking BRPOP, and sets for unique members
- ✓Hashes as field-value records and sorted sets for score-ordered rankings
- ✓The maxmemory limit and the eviction policies chosen with maxmemory-policy
- ✓Redis pub/sub delivery semantics compared with Solid Cable's table polling
- ✓How this app covers cache, job queue and Action Cable with Postgres
What Redis is: an in-memory data structure server
Redis's documentation opens its data types page with a short claim: "Redis is a data structure server". That makes it neither a relational database nor a plain cache. It's a separate network service your app talks to. It holds data in RAM, organized as a set of named data structures instead of rows…
Read the full lesson free →Curriculum
7 lessonsWhat Redis is: an in-memory data structure server
Defines Redis as an in-memory data structure server and shows this app's Gemfile has no Redis dependency.
Redis strings: the simplest data type, and what SET/GET do
Covers Redis strings, SET, GET, MSET, MGET and atomic INCR, compared with Solid Cache's row-locked increment.
Redis lists and sets: what a Sidekiq queue is built from
Explains Redis lists as the structure under a Sidekiq queue, plus sets with unique members and set operations.
Redis hashes and sorted sets: records and rankings
Covers hashes as field-value records and sorted sets for rankings, next to this app's Postgres leaderboard snapshots.
Persistence, briefly recapped, and what happens when RAM fills up
Explains maxmemory and Redis eviction policies, and how Solid Cache and Solid Queue handle growth on disk.
Pub/sub, and where Rails apps reach for Redis
Covers Redis pub/sub and its at-most-once delivery, compared with this app's polling Solid Cable adapter.
Putting it together: this app's Redis-free setup
Brings together the cache, job queue and Action Cable roles, each handled by Postgres in this app.