python.redis.unbounded_keys
Stability
High
Detects Redis key patterns that can grow unboundedly.
Why It Matters
Section titled “Why It Matters”Unbounded Redis keys:
- Memory exhaustion — Redis runs out of memory
- Performance degradation — Large datasets slow operations
- Service crash — OOM kills Redis process
Example
Section titled “Example”# ❌ Before (unbounded keys)def track_user_activity(user_id: str, action: str): key = f"user:{user_id}:actions" redis.lpush(key, action) # Grows forever!# ✅ After (bounded with max length)MAX_ACTIONS = 1000
def track_user_activity(user_id: str, action: str): key = f"user:{user_id}:actions" pipe = redis.pipeline() pipe.lpush(key, action) pipe.ltrim(key, 0, MAX_ACTIONS - 1) # Keep last 1000 pipe.execute()What Unfault Detects
Section titled “What Unfault Detects”- LPUSH/RPUSH without LTRIM
- SET accumulating without expiry
- Unbounded ZADD operations