anyway/backend/src/persistence.py
Remy Moll e951032f11
All checks were successful
Build and push docker image / Build (pull_request) Successful in 1m37s
fix memcache usage
2024-08-10 15:12:39 +02:00

29 lines
591 B
Python

from pymemcache.client.base import Client
from pymemcache import serde
import constants
class DummyClient:
_data = {}
def set(self, key, value, **kwargs):
self._data[key] = value
def set_many(self, data, **kwargs):
self._data.update(data)
def get(self, key, **kwargs):
return self._data[key]
if constants.MEMCACHED_HOST_PATH is None:
client = DummyClient()
else:
client = Client(
constants.MEMCACHED_HOST_PATH,
timeout=1,
allow_unicode_keys=True,
encoding='utf-8',
serde=serde.pickle_serde
)