Redis without a nuclear flush: targeted, the right way
On the PDP, we built the Redis cache around the `entity:id:*` namespace pattern so that data for a single entity lives in its own “pocket”. When something changes, invalidation happens selectively via `scan_iter`, without a full flush.

On the PDP, we organized the Redis cache around the entity:id:* namespace pattern. The idea is simple: data for a single entity lives in its own “pocket”, instead of being dumped into one shared bucket.
When a specific entity changes, we don’t hit the red flush button — that’s the level of “we broke prod for no reason” — and instead do granular invalidation via scan_iter: we find and clear only the related cache.
Why does this matter? At a scale of 4000+ units and dozens of issues per unit, a full cache flush would be catastrophic: a spike in database traffic, slower responses, and the classic “why is everything slow?”. This way, only what actually changed gets updated.
Against the backdrop of the constant push to optimize latency and cost, this is a must-have: less noise, less load, more control.