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

Single-Key Cache with TTL and Compression Toggle

Build a small cache adapter that stores and retrieves individual entries from a memcached cluster. Each entry should respect a per-item TTL and support optional compression when payloads exceed a configured threshold.

Capabilities

Store value with TTL

  • Storing a value with a positive TTL makes it retrievable before expiry using the same key. @test

Expire after TTL

  • A value stored with a short TTL is not returned after the TTL elapses, and fetching yields the provided default. @test

Optional compression for large payloads

  • When compression is enabled and a payload exceeds the configured threshold, storing and fetching returns the original content intact. @test

No compression when disabled

  • When compression is disabled, large payloads are stored and retrieved without compression-related errors or transformations. @test

Implementation

@generates

API

class CacheAdapter:
    def __init__(self, servers: list[str], default_ttl: int = 0, enable_compression: bool = False, compression_threshold: int = 0): ...

    def store(self, key: str, value: bytes | str, ttl_seconds: int | None = None) -> None:
        """Store the value with the supplied TTL override or the default TTL."""

    def fetch(self, key: str, default: bytes | str | None = None) -> bytes | str | None:
        """Retrieve the value if present and unexpired, otherwise return the default."""

Dependencies { .dependencies }

pylibmc { .dependency }

Provides memcached client support for single-key storage with TTL and compression controls.

Install with Tessl CLI

npx tessl i tessl/pypi-pylibmc

tile.json