Quick and small memcached client for Python
86
Build a cache adapter that customizes encoding and decoding rules for a memcached-backed client, registering its hooks so cache operations honor custom flags and treating unknown flags as misses.
@generates
class FlagAwareCacheAdapter:
def __init__(self, backend, json_flag: int = 0x99, raw_flag: int = 0):
...
def set(self, key: str, value, ttl: int = 0) -> bool:
"""Store a value with optional TTL using the backend."""
def get(self, key: str, default=None):
"""Fetch a value, returning default when treating data as a miss."""
def serialize(self, value) -> tuple[bytes, int]:
"""Encode a value and return (payload, flag) pair for backend storage."""
def deserialize(self, data: bytes, flag: int):
"""Decode backend payloads, treating unsupported flags as cache misses."""Memcached client that allows overriding serialization hooks and using cache-miss sentinels.
Install with Tessl CLI
npx tessl i tessl/pypi-pylibmcevals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10