get

privex.helpers.cache.get(key: str, default: Any = None, fail: bool = False) → Any[source]

Return the value of cache key key. If the key wasn’t found, or it was expired, then default will be returned.

Optionally, you may choose to pass fail=True, which will cause this method to raise CacheNotFound instead of returning default when a key is non-existent / expired.

Parameters
  • key (str) – The cache key (as a string) to get the value for, e.g. example:test

  • default (Any) – If the cache key key isn’t found / is expired, return this value (Default: None)

  • fail (bool) – If set to True, will raise CacheNotFound instead of returning default when a key is non-existent / expired.

Raises

CacheNotFound – Raised when fail=True and key was not found in cache / expired.

Return Any value

The value of the cache key key, or default if it wasn’t found.