tessl install tessl/pypi-pylibmc@1.6.0Quick and small memcached client for Python
Agent Success
Agent success rate when using this tile
86%
Improvement
Agent success rate improvement when using this tile compared to baseline
1.04x
Baseline
Agent success rate without this tile
83%
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.