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

UTF-8 Normalized Cache Bridge

A small cache wrapper that guarantees text and bytes keys behave as aliases of the same entry when talking to a memcached backend.

Capabilities

Unified single-key operations

  • Setting value {"source": "text"} using key "café-token" and reading with b"caf\xc3\xa9-token" returns the stored value with no duplicate entry created @test
  • Overwriting the same entry via the bytes form and reading via the text form returns the updated payload instead of the original @test

Bulk fetch normalization

  • After storing entries for keys "alpha" and b"brav\xc3\xb3", calling get_many([b"alpha", "bravó"]) returns both cached values keyed as b"alpha" and "bravó" without duplicating entries @test

Deletion coherence

  • Deleting an entry with b"café-token" removes the value so that a follow-up read with "café-token" returns the supplied default @test

Implementation

@generates

API

class CacheBridge:
    def __init__(self, servers: list[str] | tuple[str, ...], *, default_ttl: int = 0): ...
    def set_value(self, key: str | bytes, value: object, ttl: int | None = None) -> bool: ...
    def get_value(self, key: str | bytes, default: object | None = None) -> object | None: ...
    def get_many(self, keys: list[str | bytes]) -> dict[str | bytes, object]: ...
    def delete_value(self, key: str | bytes) -> bool: ...

Dependencies { .dependencies }

pylibmc { .dependency }

Memcached client with UTF-8 normalization between text and byte keys.

Install with Tessl CLI

npx tessl i tessl/pypi-pylibmc

tile.json