Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /Ap6pack_malwar /src /malwar /cache /base.py
| """Abstract cache backend interface with TTL support.""" | |
| from __future__ import annotations | |
| import abc | |
| class CacheBackend(abc.ABC): | |
| """Abstract base class for cache backends. | |
| All backends must support async get/set/delete/exists operations | |
| with optional TTL (time-to-live) in seconds. | |
| """ | |
| async def get(self, key: str) -> str | None: | |
| """Retrieve a cached value by key. | |
| Returns: | |
| The cached string value, or ``None`` if the key does not | |
| exist or has expired. | |
| """ | |
| async def set(self, key: str, value: str, ttl: int | None = None) -> None: | |
| """Store a value in the cache. | |
| Args: | |
| key: Cache key. | |
| value: String value to store. | |
| ttl: Time-to-live in seconds. ``None`` means no expiry. | |
| """ | |
| async def delete(self, key: str) -> bool: | |
| """Delete a key from the cache. | |
| Returns: | |
| ``True`` if the key existed and was deleted, ``False`` otherwise. | |
| """ | |
| async def exists(self, key: str) -> bool: | |
| """Check whether a key exists (and has not expired). | |
| Returns: | |
| ``True`` if the key exists and is valid. | |
| """ | |
| async def clear(self) -> int: | |
| """Flush all keys from this cache. | |
| Returns: | |
| The number of keys removed. | |
| """ | |
| async def size(self) -> int: | |
| """Return the number of live (non-expired) entries in the cache.""" | |
| async def close(self) -> None: | |
| """Release any resources held by the backend.""" | |
Xet Storage Details
- Size:
- 1.73 kB
- Xet hash:
- 8b06dbd8504c9c2dd5e305410d3b968969c962326d99e6c73911084e0b782b97
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.