Quick and small memcached client for Python
86
A helper that builds cache clients for TCP, UDP, or UNIX socket endpoints with optional binary protocol and SASL authentication.
["127.0.0.1:11211", "cache.example.com:11211"], the factory returns a client configured to talk to each endpoint without errors. @testudp: and a UNIX socket path (e.g., /tmp/memcached.sock), the factory builds a client that can perform a basic set/get roundtrip through those transports. @testuse_binary is true, the created client uses the binary protocol while still accepting mixed server definitions. @testusername and password, the factory enables the binary protocol automatically and returns a client that authenticates via SASL before use. @testusername or password is provided, the factory raises a configuration error before attempting to connect. @test@generates
from dataclasses import dataclass
from typing import Iterable, Optional
@dataclass
class ClientConfig:
servers: Iterable[str]
use_binary: bool = False
username: Optional[str] = None
password: Optional[str] = None
def create_cache_client(config: ClientConfig):
"""Return a ready-to-use cache client configured for the provided servers and optional SASL credentials."""Memcached client used to open TCP, UDP, or UNIX socket connections with optional binary protocol and SASL authentication.
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