mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-26 05:48:36 +08:00
24 lines
555 B
Python
24 lines
555 B
Python
import os
|
|
|
|
import redis
|
|
|
|
# Redis configuration
|
|
REDIS_HOST = os.environ.get('REDIS_HOST', 'localhost')
|
|
REDIS_PORT = int(os.environ.get('REDIS_PORT', '6379'))
|
|
REDIS_PASSWORD = os.environ.get('REDIS_PASSWORD', '')
|
|
REDIS_DB = int(os.environ.get('REDIS_DB', '0'))
|
|
|
|
|
|
def create_redis_client():
|
|
return redis.Redis(
|
|
host=REDIS_HOST,
|
|
port=REDIS_PORT,
|
|
password=REDIS_PASSWORD,
|
|
db=REDIS_DB,
|
|
socket_timeout=2,
|
|
)
|
|
|
|
|
|
def get_redis_authed_url():
|
|
return f'redis://:{REDIS_PASSWORD}@{REDIS_HOST}:{REDIS_PORT}/{REDIS_DB}'
|