added redis adapter #1

Merged
brian merged 13 commits from collect-code-from-other-repos into main 2025-09-14 20:42:51 +02:00
Showing only changes of commit 524bd0f06b - Show all commits
@@ -62,12 +62,15 @@ class RedisAdapter(
# Prepare arguments
uri = str(os.getenv(self.uri_env_var_name))
# Connect client
try:
client = redis.Redis.from_url(
url=uri,
socket_connect_timeout=10,
)
if not client.ping():
raise ConnectionError(f"Could not connect to Redis at {uri}")
except (redis.ConnectionError, redis.TimeoutError) as exc:
raise ConnectionError(f"Could not connect to Redis at {uri}") from exc
# Persist client
self._client = client
@@ -128,7 +131,7 @@ class RedisAdapter(
self._client.json().delete(key)
self.logger.debug(f"Deleted {key}")
async def _list_keys(self, pattern: str) -> list[str]:
def _list_keys(self, pattern: str) -> list[str]:
"""List keys in Redis matching a pattern."""
# Check input
if not isinstance(pattern, str) or len(pattern) == 0: