betty.cache.no_op module - Betty 0.4.0a4 documentation

Hide navigation sidebar
Hide table of contents sidebar
Skip to content
Back to top
View this page
Toggle table of contents sidebar

# betty.cache.no_op module

Provide no-op caching.

class betty.cache.no_op.NoOpCache

  Bases: `Cache`[`Any`]

  Provide a cache that does nothing.

  async clear() → None

    Clear all items from the cache.

  async delete(cache_item_id: str) → None

    Delete the cache item with the given ID.

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

    Get the cache item with the given ID.

  getset(cache_item_id: str) → AsyncContextManager[tuple[CacheItem[Any] | None, Callable[[Any], Awaitable[None]]]]
  getset(cache_item_id: str, *, wait: Literal[False] = False) → AsyncContextManager[tuple[CacheItem[Any] | None, Callable[[Any], Awaitable[None]] | 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

    Add or update a cache item.

  with_scope(scope: str) → Self

    Return a new nested cache with the given scope.