Module

cache.protocol

Cache backend protocol — structural typing for cache stores.

Classes

CacheBackend 4
Protocol for cache backends. All methods are async. Values are bytes-based for backend flexibility.

Protocol for cache backends.

All methods are async. Values are bytes-based for backend flexibility.

Methods

get 1 bytes | None
Get a cached value. Returns None on miss.
async
async def get(self, key: str) -> bytes | None
Parameters
Name Type Description
key
Returns
bytes | None
set 3
Set a cached value. ttl=0 means no expiration.
async
async def set(self, key: str, value: bytes, ttl: int = 0) -> None
Parameters
Name Type Description
key
value
ttl Default:0
delete 1
Delete a cached key.
async
async def delete(self, key: str) -> None
Parameters
Name Type Description
key
clear 0
Clear all cached entries.
async
async def clear(self) -> None