Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
joocer committed Sep 11, 2024
1 parent 53b4462 commit c5f8bc7
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions opteryx/managers/cache/memcached.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,14 @@ def get(self, key: bytes) -> Union[bytes, None]:
self.skips += 1
return None
try:
response = self._server.get(key, None)
print(key)
response = self._server.get(bytes(key))
self._consecutive_failures = 0
if response:
self.hits += 1
return bytes(response)
except Exception as err: # pragma: no cover
# DEBUG: log(f"Unable to 'get' Memcache cache {type(err)}")
self._consecutive_failures += 1
if self._consecutive_failures >= MAXIMUM_CONSECUTIVE_FAILURES:
import datetime
Expand All @@ -120,10 +122,11 @@ def get(self, key: bytes) -> Union[bytes, None]:
def set(self, key: bytes, value: bytes) -> None:
if self._consecutive_failures < MAXIMUM_CONSECUTIVE_FAILURES:
try:
self._server.set(key, value)
self._server.set(bytes(key), value)
self.sets += 1
except Exception as err:
# if we fail to set, stop trying
# DEBUG: log(f"Unable to 'set' Memcache cache {err}")
self._consecutive_failures = MAXIMUM_CONSECUTIVE_FAILURES
self.errors += 1
import datetime
Expand All @@ -137,7 +140,7 @@ def set(self, key: bytes, value: bytes) -> None:
def touch(self, key: bytes):
if self._consecutive_failures < MAXIMUM_CONSECUTIVE_FAILURES:
try:
self._server.touch(key)
self._server.touch(bytes(key))
self.touches += 1
except Exception as err: # nosec
if not err:
Expand Down

0 comments on commit c5f8bc7

Please sign in to comment.