CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-pylibmc

Quick and small memcached client for Python

86

1.03x
Overview
Eval results
Files

task.mdevals/scenario-3/

Multi-Transport Cache Client Factory

A helper that builds cache clients for TCP, UDP, or UNIX socket endpoints with optional binary protocol and SASL authentication.

Capabilities

Connects to multiple transports

  • Given TCP hosts like ["127.0.0.1:11211", "cache.example.com:11211"], the factory returns a client configured to talk to each endpoint without errors. @test
  • Given UDP endpoints prefixed with udp: 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. @test

Binary protocol toggle

  • When use_binary is true, the created client uses the binary protocol while still accepting mixed server definitions. @test

SASL authentication handshake

  • When provided both username and password, the factory enables the binary protocol automatically and returns a client that authenticates via SASL before use. @test
  • If only one of username or password is provided, the factory raises a configuration error before attempting to connect. @test

Implementation

@generates

API

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."""

Dependencies { .dependencies }

pylibmc { .dependency }

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-pylibmc

tile.json