27 lines
534 B
Python
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'
|
|
)
|