Closes #219
All checks were successful
Analysis / SonarCloud (push) Successful in 1m35s

This commit is contained in:
2025-07-07 23:35:21 +02:00
parent ad38dbdca1
commit 3110bb64b1
4 changed files with 15 additions and 15 deletions

View File

@@ -69,28 +69,28 @@ class CacheMemcached(Cache):
def get_object(self, key: str) -> Any | None:
raise NotImplementedError()
def set_json(self, key: str, value: Any) -> None:
def set_json(self, key: str, value: Any, ttl_seconds: Optional[int] = None) -> None:
key = self._get_prefixed_key(key)
try:
self.client.set(key, _json_to_string(value))
self.client.set(key, _json_to_string(value), expire=0 if ttl_seconds is None else ttl_seconds)
logger.debug("Set json cache key '%s'", key)
except Exception as exc:
logger.error("Could not set json cache key '%s' due to: %s", key, exc)
return None
def set_string(self, key: str, value: str) -> None:
def set_string(self, key: str, value: str, ttl_seconds: Optional[int] = None) -> None:
key = self._get_prefixed_key(key)
try:
self.client.set(key, value)
self.client.set(key, value, expire=0 if ttl_seconds is None else ttl_seconds)
logger.debug("Set string cache key '%s'", key)
except Exception as exc:
logger.error("Could not set string cache key '%s' due to: %s", key, exc)
return None
# TODO Implement binary serialization
def set_object(self, key: str, value: Any) -> None:
def set_object(self, key: str, value: Any, ttl_seconds: Optional[int] = None) -> None:
raise NotImplementedError()
def delete(self, key: str) -> None: