CAR-1283: align cache.py to dev (bytes-aware decode, drop str() cast)
This commit is contained in:
@@ -35,10 +35,12 @@ class CacheClient:
|
|||||||
async def get(self, key: str) -> str | None:
|
async def get(self, key: str) -> str | None:
|
||||||
if not self._client:
|
if not self._client:
|
||||||
return None
|
return None
|
||||||
result = await self._client.get(key)
|
value = await self._client.get(key)
|
||||||
if result is None:
|
if value is None:
|
||||||
return None
|
return None
|
||||||
return str(result)
|
if isinstance(value, bytes):
|
||||||
|
return value.decode("utf-8", errors="replace")
|
||||||
|
return value
|
||||||
|
|
||||||
async def set(self, key: str, value: str, ttl_seconds: int = 300) -> None:
|
async def set(self, key: str, value: str, ttl_seconds: int = 300) -> None:
|
||||||
if not self._client:
|
if not self._client:
|
||||||
|
|||||||
Reference in New Issue
Block a user