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

Adaptive Cache Compression Overrides

A helper around a memcached client that applies per-write compression thresholds and compression levels while keeping sensible defaults for future operations.

Capabilities

Default thresholds and levels set at construction are used whenever per-call overrides are omitted.

Per-item compression thresholds

  • Using store with an override threshold of 256 bytes, storing a ~100-byte payload and then a ~1KB payload both return True and load returns the original bytes for each; the override only applies to that call. @test

Compression level overrides

  • When a write specifies a custom compression level, the value round-trips correctly and later writes without an override fall back to the default level set at construction. @test

Bulk writes honor shared overrides

  • Writing multiple entries with shared threshold and level overrides persists all entries, returns an empty sequence for failures, and each entry can be retrieved unchanged. @test

Implementation

@generates

API

from typing import Any, Mapping, Optional, Sequence

class AdaptiveCache:
    def __init__(self, client, default_min_bytes: int = 0, default_level: int = -1) -> None:
        ...

    def store(self, key: str, value: Any, *, min_bytes: Optional[int] = None, level: Optional[int] = None) -> bool:
        ...

    def store_many(self, values: Mapping[str, Any], *, min_bytes: Optional[int] = None, level: Optional[int] = None) -> Sequence[str]:
        ...

    def load(self, key: str, default: Any = None) -> Any:
        ...

Dependencies { .dependencies }

pylibmc { .dependency }

Memcached client with built-in compression threshold and level controls.

Install with Tessl CLI

npx tessl i tessl/pypi-pylibmc

tile.json