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-1/

Binary-Protected Cache Access

Configure a memcached client that always uses the binary protocol with SASL authentication and exposes a simple health check.

Capabilities

Binary protocol enforced

  • Creating a client without explicitly enabling the binary protocol raises an error before attempting any network operations. @test
  • Providing an empty server list results in a clear error instead of building a client with invalid configuration. @test

SASL credentials required

  • Omitting either username or password causes client creation to fail immediately with an authentication-related error. @test
  • When valid credentials are provided, the client is instantiated ready for authenticated requests without additional toggles. @test

Authenticated health check

  • A ping style call stores and retrieves a sentinel value using the authenticated client and returns True on success. @test
  • If the authenticated call fails due to bad credentials, the health check surfaces the authentication error instead of masking it. @test

Implementation

@generates

API

from dataclasses import dataclass
from typing import Iterable, Any

@dataclass
class CacheAuth:
    servers: Iterable[str]
    username: str
    password: str
    timeout: float | None = None

def build_authenticated_client(config: CacheAuth) -> Any:
    """Create a cache client that uses the binary protocol with SASL credentials, raising on invalid configuration."""


def ping_cache(client: Any, key: str = "__ping__", ttl: int = 5) -> bool:
    """Perform an authenticated write/read using the given client; returns True on success, raises on authentication failures."""

Dependencies { .dependencies }

pylibmc { .dependency }

Memcached client with binary protocol and SASL support.

Install with Tessl CLI

npx tessl i tessl/pypi-pylibmc

tile.json