betty.cache.no_op module

Provide no-op caching.

class betty.cache.no_op.NoOpCache[source]

Bases: Cache[Any]

Provide a cache that does nothing.

async clear() None[source]

Clear all items from the cache.

Return type:

None

async delete(cache_item_id: str) None[source]

Delete the cache item with the given ID.

Parameters:

cache_item_id (str)

Return type:

None

get(cache_item_id: str) collections.abc.AsyncIterator[betty.cache.CacheItem[Any] | None][source]

Get the cache item with the given ID.

Parameters:

cache_item_id (str)

Return type:

collections.abc.AsyncIterator[typing.Optional[betty.cache.CacheItem[typing.Any]]]

getset(cache_item_id: str, *, wait: bool = True) AsyncContextManager[tuple[betty.cache.CacheItem[Any] | None, collections.abc.Callable[[Any], collections.abc.Awaitable[None]] | None]][source]

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.

Parameters:
Return type:

typing.AsyncContextManager[tuple[typing.Optional[betty.cache.CacheItem[typing.Any]], collections.abc.Callable[[typing.Any], collections.abc.Awaitable[None]] | None]]

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

Add or update a cache item.

Parameters:
Return type:

None

with_scope(scope: str) Self[source]

Return a new nested cache with the given scope.

Parameters:

scope (str)

Return type:

typing.Self