S
Sheba ISP ERPDOCS
Integrations

Redis Caching & Distributed Locking Integration

Redis 7 configuration for Celery message broker, Django cache backend, and distributed lock coordination.

Redis Caching & Distributed Locking Integration

IMPLEMENTED

Redis 7 serves as the unified message broker, application cache, and distributed lock coordinator for the entire backend.


1. Multi-Database / Key Namespace Partitioning

DB / PrefixUsageKey ExpirationDescription
celery (DB 0)Celery Queue BrokerDynamicFIFO task queue for asynchronous jobs
cache: (DB 0)Django Redis Cache5 - 60 minutesCached dashboard metrics, tenant domains
lock: (DB 0)Distributed Locks60 - 300 secondsMutual exclusion locks preventing double billing
throttle: (DB 0)DRF Throttling60 secondsSliding-window request rate limits

2. Distributed Locking Implementation

Implemented in backend/apps/core/lock.py:

  • Uses Redis atomic SET key value NX PX timeout commands.
  • Ensures locks expire automatically if a worker process crashes, preventing permanent deadlock.

On this page