Quick and small memcached client for Python
86
Utility for clearing and refreshing cache entries on a memcached-backed client, emphasizing targeted removal, bulk cleanup, TTL extension, and full flush behavior.
True and subsequent retrieval of that key yields a cache miss. @testFalse without affecting other stored values. @testFalse and does not create data. @test@generates
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."""Memcached client used for cache operations and TTL control. @satisfied-by
Install with Tessl CLI
npx tessl i tessl/pypi-pylibmcevals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10