"""
Provide caching that stores cache items in volatile memory.
"""
from __future__ import annotations
from collections.abc import MutableMapping, Sequence
from typing import TypeAlias, Generic, Self, cast, TypeVar, final
from typing_extensions import override
from betty.cache import CacheItem
from betty.cache._base import _CommonCacheBase, _StaticCacheItem
from betty.typing import threadsafe
_CacheItemValueContraT = TypeVar("_CacheItemValueContraT", contravariant=True)
_MemoryCacheStore: TypeAlias = MutableMapping[
str,
"CacheItem[_CacheItemValueContraT] | None | _MemoryCacheStore[_CacheItemValueContraT]",
]
[docs]
@final
@threadsafe
class MemoryCache(
_CommonCacheBase[_CacheItemValueContraT], Generic[_CacheItemValueContraT]
):
"""
Provide a cache that stores cache items in volatile memory.
"""