"""
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, TYPE_CHECKING, TypeVar
from typing_extensions import override
from betty.cache import CacheItem
from betty.cache._base import _CommonCacheBase, _StaticCacheItem
if TYPE_CHECKING:
from betty.locale import Localizer
_CacheItemValueContraT = TypeVar("_CacheItemValueContraT", contravariant=True)
_MemoryCacheStore: TypeAlias = MutableMapping[
str,
"CacheItem[_CacheItemValueContraT] | None | _MemoryCacheStore[_CacheItemValueContraT]",
]
[docs]
class MemoryCache(
_CommonCacheBase[_CacheItemValueContraT], Generic[_CacheItemValueContraT]
):
"""
Provide a cache that stores cache items in volatile memory.
"""