mirror of https://github.com/kortix-ai/suna.git
bring back og redis file
This commit is contained in:
parent
d4e2665e6b
commit
551430ffd6
|
@ -80,7 +80,7 @@ def initialize():
|
||||||
socket_connect_timeout=5.0, # Connection timeout
|
socket_connect_timeout=5.0, # Connection timeout
|
||||||
retry_on_timeout=True, # Auto-retry on timeout
|
retry_on_timeout=True, # Auto-retry on timeout
|
||||||
health_check_interval=30, # Check connection health every 30 seconds
|
health_check_interval=30, # Check connection health every 30 seconds
|
||||||
max_connections=100 # Limit connections to prevent overloading
|
max_connections=10 # Limit connections to prevent overloading
|
||||||
)
|
)
|
||||||
|
|
||||||
return client
|
return client
|
||||||
|
@ -141,29 +141,10 @@ async def get_client():
|
||||||
|
|
||||||
# Centralized Redis operation functions with built-in retry logic
|
# Centralized Redis operation functions with built-in retry logic
|
||||||
|
|
||||||
async def set(key, value, ex=None, nx=None, xx=None):
|
async def set(key, value, ex=None):
|
||||||
"""
|
"""Set a Redis key with automatic retry."""
|
||||||
Set a Redis key with automatic retry.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
key: The key to set
|
|
||||||
value: The value to set
|
|
||||||
ex: Expiration time in seconds
|
|
||||||
nx: Only set the key if it does not already exist
|
|
||||||
xx: Only set the key if it already exists
|
|
||||||
"""
|
|
||||||
redis_client = await get_client()
|
redis_client = await get_client()
|
||||||
|
return await with_retry(redis_client.set, key, value, ex=ex)
|
||||||
# Build the kwargs based on which parameters are provided
|
|
||||||
kwargs = {}
|
|
||||||
if ex is not None:
|
|
||||||
kwargs['ex'] = ex
|
|
||||||
if nx is not None:
|
|
||||||
kwargs['nx'] = nx
|
|
||||||
if xx is not None:
|
|
||||||
kwargs['xx'] = xx
|
|
||||||
|
|
||||||
return await with_retry(redis_client.set, key, value, **kwargs)
|
|
||||||
|
|
||||||
async def get(key, default=None):
|
async def get(key, default=None):
|
||||||
"""Get a Redis key with automatic retry."""
|
"""Get a Redis key with automatic retry."""
|
||||||
|
|
Loading…
Reference in New Issue