Chapter

Beyond cache and production

Redis is more than a cache: rate limiting, queues, and pub/sub. Then the production side - persistence, eviction, security, a full Docker stack, and troubleshooting when things break.

Redis Basics 8 Lessons from courses

About this chapter

You have Redis working as a cache. This final chapter shows what else it does well - rate limiting, background jobs, and messaging - and then covers what you need to run it in production: persistence, memory limits, security, a complete Docker stack, and how to diagnose problems.

Lessons from courses

  1. 1 Rate limiting with Redis Build a fixed-window rate limiter with Redis rate limiting: INCR and EXPIRE per user, plus how Laravel's throttle middleware uses the same counter.
  2. 2 Queues and background jobs Set up a Laravel Redis queue: dispatch background jobs, run queue:work, and retry failed jobs with queue:retry. Why Redis lists fit a queue.
  3. 3 Publish/subscribe Learn Redis pub/sub with SUBSCRIBE and PUBLISH. Send fire-and-forget live messages to connected clients, and see how it differs from a persistent queue.
  4. 4 Persistence: RDB and AOF Does Redis survive a restart? Learn how Redis persists in-memory data to disk with RDB snapshots and AOF, their trade-offs, and when a cache needs neither.
  5. 5 Eviction policies Set a Redis memory limit with maxmemory and choose a maxmemory-policy. Compare noeviction, allkeys-lru, allkeys-lfu, volatile-lru, and volatile-ttl for a cache.
  6. 6 Securing Redis Secure Redis the right way: set a password with requirepass or ACLs, bind to localhost, use protected-mode, and never expose port 6379 to the internet.
  7. 7 A Laravel + Redis Docker stack A full annotated docker-compose.yml for Laravel with a php-fpm app, redis:7, and a queue worker - plus the .env wiring and how services find each other.
  8. 8 Troubleshooting Redis Fix common Redis errors: Connection refused, NOAUTH, OOM maxmemory, WRONGTYPE, and slow commands - and diagnose them with INFO, MONITOR, and SLOWLOG.
Redis Basics Go to course