Ctrl + k

or run

tessl search
Log in

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/pylibmc@1.6.x
tile.json

tessl/pypi-pylibmc

tessl install tessl/pypi-pylibmc@1.6.0

Quick and small memcached client for Python

Agent Success

Agent success rate when using this tile

86%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.04x

Baseline

Agent success rate without this tile

83%

task.mdevals/scenario-9/

Prefixed Bulk Cache

Create a small cache helper that batches reads and writes for a group of keys while automatically applying a shared prefix so callers never handle namespacing themselves.

Capabilities

Bulk store with shared prefix

  • Storing multiple user settings at once (ids u1, u2) and then reading those ids returns both values keyed by the original ids; no prefixed keys are exposed to callers. @test

Bulk fetch ignoring misses

  • Requesting ids a, b, missing after only a and b are stored returns just a and b; absent entries are omitted rather than set to null/None. @test

Prefix isolation

  • When an unprefixed key session123 already exists with one value, using the helper with prefix sess: to store and fetch session123 returns only the namespaced value, demonstrating isolation between prefixed and unprefixed keys. @test

Implementation

@generates

API

from typing import Any, Dict, Iterable, List, Optional

class PrefixedCache:
    def __init__(self, client: Any, prefix: str, default_ttl: int = 0) -> None:
        """Wrap a cache client, applying `prefix` to every stored/fetched key."""

    def store_all(self, items: Dict[str, Any], ttl: Optional[int] = None) -> List[str]:
        """Persist a mapping of ids to values with the shared prefix; returns ids that failed to store."""

    def fetch_existing(self, ids: Iterable[str]) -> Dict[str, Any]:
        """Fetch multiple ids in one call, returning only the ids found (without the prefix)."""

Dependencies { .dependencies }

pylibmc { .dependency }

Memcached client providing bulk operations and transparent key prefix handling.