rberga06.utils.cache.Cache#
- class rberga06.utils.cache.Cache(_: _T | _U | Literal[_Sentinels.DEFAULT] = _Sentinels.DEFAULT)#
Bases:
Generic
[_T
,_U
]A cache.
Methods
__init__
([_])clear
()Clar obj's cache (if any).
default
()The default value (empty cache).
get
(obj, /, *[, strict])Return obj's cache (or raise ValueError(...) if strict, else return None).
has
(obj, /)Check if obj has a cache of this type.
read
(*[, strict])Read self's cache.
set
(obj, /)Decorator: set self as obj's cache.
Attributes
is_empty
- classmethod default() _U #
The default value (empty cache).
- classmethod get(obj: object, /, *, strict: bool = True) Self | None #
Return obj’s cache (or raise ValueError(…) if strict, else return None).
- set(obj: _X, /) _X #
Decorator: set self as obj’s cache.