MukeshKapoor25 commited on
Commit
72e63d6
·
1 Parent(s): f553d39

fix(redis): Validate REDIS_URL format in Redis client settings

Browse files
Files changed (1) hide show
  1. app/cache.py +5 -2
app/cache.py CHANGED
@@ -28,9 +28,12 @@ def create_redis_connection(**kwargs) -> redis.Redis:
28
  # -----------------------------------------------------------------------------
29
  def _redis_from_settings() -> redis.Redis:
30
  """Create Redis client from settings using insightfy patterns."""
31
- if CACHE_URL:
 
 
 
32
  return redis.from_url(
33
- CACHE_URL,
34
  decode_responses=True,
35
  socket_timeout=5,
36
  socket_connect_timeout=5,
 
28
  # -----------------------------------------------------------------------------
29
  def _redis_from_settings() -> redis.Redis:
30
  """Create Redis client from settings using insightfy patterns."""
31
+ cache_url = (CACHE_URL or "").strip()
32
+ if cache_url:
33
+ if not cache_url.startswith(("redis://", "rediss://", "unix://")):
34
+ raise ValueError("REDIS_URL must start with redis://, rediss://, or unix://")
35
  return redis.from_url(
36
+ cache_url,
37
  decode_responses=True,
38
  socket_timeout=5,
39
  socket_connect_timeout=5,