cement.core.cache
Cement core cache module.
- class cement.core.cache.CacheHandler(**kw: Any)[source]
Bases:
CacheInterface,HandlerCache handler implementation.
- class cement.core.cache.CacheInterface(**kw: Any)[source]
Bases:
InterfaceThis class defines the Cache Interface. Handlers that implement this interface must provide the methods and attributes defined below. In general, most implementations should sub-class from the provided
CacheHandlerbase class as a starting point.- abstractmethod delete(key: str) bool[source]
Deletes a key/value from the cache.
- Parameters:
key – The key in the cache to delete
- Returns:
Trueif the key is successfully deleted,Falseotherwise- Return type:
- abstractmethod get(key: str, fallback: Any = None) Any[source]
Get the value for a key in the cache.
If the key does not exist or the key/value in cache is expired, this functions must return
fallback(which in turn must default toNone).- Parameters:
key (str) – The key of the value stored in cache
- Keyword Arguments:
fallback – Optional value that is returned if the cache is expired or the key does not exist.
- Returns:
Whatever the value is in the cache, or the
fallback- Return type:
Unknown
- abstractmethod set(key: str, value: Any, time: int | None = None) None[source]
Set the key/value in the cache for a set amount of
time.- Parameters:
key (str) – The key of the value to store in cache
value (unknown) – The value of that key to store in cache
- Keyword Arguments:
time (int) – A one-off expire time in seconds (or
None. If no time is given, then a default value is used (determined by the implementation).
Returns: None