Development › Redis

Redis

Redis backs cache, queues (optional), distributed locks, rate limiting, and short-lived idempotency / temporary state.

#Uses in this architecture

ConcernContract / mechanism
CacheCacheStore / Laravel cache store
LocksDistributedLock
IdempotencyIdempotencyStore
QueuesLaravel redis queue connection (optional)
Rate limitingLaravel RateLimiter + Redis

#Rules

  1. Domain code never imports Redis clients.
  2. Prefer Core contracts so implementations can swap (array store in tests, Redis in prod).
  3. Set TTLs on ephemeral keys (idempotency, locks, rate windows).
  4. Do not treat Redis as the system of record for business entities — Postgres/MySQL owns durable state.

#Local configuration

With Docker Compose, the redis service is available to app and worker.

Example env:

REDIS_CLIENT=predis
REDIS_HOST=redis
REDIS_PORT=6379
REDIS_PASSWORD=null

CACHE_STORE=redis
QUEUE_CONNECTION=redis

For pure unit tests, phpunit.xml uses CACHE_STORE=array and QUEUE_CONNECTION=sync.

#Operational notes

Edit this page on GitHub