betty.cache.no_op module

Provide no-op caching.

final class betty.cache.no_op.NoOpCache[source]

Bases: Cache[Any]

Provide a cache that does nothing.

This is thread-safe, which means you can safely use this between different threads.

async clear() None[source]

Clear all items from the cache.

async delete(cache_item_id: str) None[source]

Delete the cache item with the given ID.

get(cache_item_id: str) AsyncIterator[CacheItem[Any] | None][source]

Get the cache item with the given ID.

getset(cache_item_id: str) AsyncContextManager[tuple[CacheItem[Any] | None, Callable[[Any], Awaitable[None]]], bool | None][source]
getset(cache_item_id: str, *, wait: Literal[False] = False) AsyncContextManager[tuple[CacheItem[Any] | None, Callable[[Any], Awaitable[None]] | None], bool | None]

Get the cache item with the given ID, and provide a setter to add or update it within the same atomic operation.

If wait is False and no lock can be acquired, return None, None. Otherwise return: 0. A cache item if one could be found, or else None. 1. An asynchronous setter that takes the cache item’s value as its only argument.

async set(cache_item_id: str, value: Any, *, modified: int | float | None = None) None[source]

Add or update a cache item.

with_scope(scope: str) Self[source]

Return a new nested cache with the given scope.