anyway/backend/src/persistence.py
2024-11-18 16:52:01 +01:00

27 lines
534 B
Python

from pymemcache.client.base import Client
from .constants import MEMCACHED_HOST_PATH
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 MEMCACHED_HOST_PATH is None:
client = DummyClient()
else:
client = Client(
MEMCACHED_HOST_PATH,
timeout=1,
allow_unicode_keys=True,
encoding='utf-8'
)