cache_get_or_set¶
-
classmethod
CacheManagerMixin.
cache_get_or_set
(key: str, value: Any, timeout: Optional[Union[decimal.Decimal, int, float, str]] = <class 'privex.helpers.types.AutoDetected'>, auto_prefix=True)[source]¶ This is a simple helper method which calls
cached.get_or_set()
- while automatically prependingcache_prefix
andcache_sep
before the key.- Parameters
key (str) – The cache key (as a string) to get the value for, e.g.
example:test
value (Any) – The value to store in the cache key
key
timeout (int) – The amount of seconds to keep the data in cache. Pass
None
to disable expiration.auto_prefix (bool) – If set to
True
, will auto-prependcache_prefix
tokey
if it’s not present.
- Raises
CacheNotFound – Raised when
fail=True
andkey
was not found in cache / expired.- Return Any value
The value of the cache key
key
, ordefault
if it wasn’t found.