Hands-on guide series
Redis: Caching, Sessions and Queues: A Hands-On Guide
A six-part, hands-on guide to running Redis on a single VPS: the five core data types, cache-aside with TTL and eviction, RDB and AOF persistence, a session store and rate limiter, pub/sub and queues with Streams, and security hardening. Every command tested on a live Ubuntu 24.04 server.
What you will build
Security is layers, not a switch. Each part closes a different category of attack, from the automated sweep that finds a brand-new server, to the day one gets in anyway. Read them in order, or jump to what you need.
- 1
Install Redis and the Data ModelInstall Redis on a bare Ubuntu 24.04 slice, watch a repeat read become a cache hit served from memory, then learn the five redis data types your app will use.10 min - 2
Caching Patterns: Cache-Aside, TTL and EvictionPut redis caching in front of a slow store: cache-aside with GET and SET, expiry with EX and TTL, then eviction under a memory cap.8 min - 3
Persistence and Durability: RDB and AOFMake redis persistence real: trigger an RDB snapshot with BGSAVE, enable the append-only file, and prove the data survives a full restart.8 min - 4
Session Store and Rate LimiterBuild a redis rate limiter with INCR and EXPIRE that blocks the sixth request, and store a login session as a hash with a sliding TTL that refreshes on every access.7 min - 5
Pub/Sub and Simple QueuesUse redis pub/sub to fan a message out to a live subscriber, move work through a list queue with LPUSH and BRPOP, then meet Streams as the durable upgrade.8 min - 6
Security HardeningRedis security on a live server: require a password, stay on loopback, rename risky commands, prove TLS encrypts the wire, and firewall the port.8 min