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

Cache Janitor

Utility for clearing and refreshing cache entries on a memcached-backed client, emphasizing targeted removal, bulk cleanup, TTL extension, and full flush behavior.

Capabilities

Delete single entry

  • Removing an existing key returns True and subsequent retrieval of that key yields a cache miss. @test
  • Removing a missing key returns False without affecting other stored values. @test

Delete multiple entries at once

  • Deleting a mix of existing and missing keys returns a mapping of every requested key to whether it was removed, and only existing keys disappear from the cache. @test

Refresh TTL for hot items

  • Refreshing the expiration for a present key extends its life while preserving the stored value; doing the same for a missing key returns False and does not create data. @test

Flush all cached data

  • Flushing the cache clears every key across configured servers so that previously stored values read back as misses until rewritten. @test

Implementation

@generates

API

from typing import Iterable, Mapping

class CacheJanitor:
    def __init__(self, client) -> None:
        """client is a configured cache client supporting basic read/write/delete semantics."""

    def remove(self, key: str) -> bool:
        """Remove a single key; returns True if the key was present and removed, False otherwise."""

    def remove_many(self, keys: Iterable[str]) -> Mapping[str, bool]:
        """Bulk-remove keys; returns a mapping of each provided key to whether it was removed."""

    def refresh_ttl(self, key: str, ttl_seconds: int) -> bool:
        """Push back the expiration for a key without altering its value."""

    def flush(self) -> None:
        """Clear the entire cache."""

Dependencies { .dependencies }

pylibmc { .dependency }

Memcached client used for cache operations and TTL control. @satisfied-by

Install with Tessl CLI

npx tessl i tessl/pypi-pylibmc

tile.json