get¶
-
abstract
CacheAdapter.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, thendefaultwill be returned.Optionally, you may choose to pass
fail=True, which will cause this method to raiseCacheNotFoundinstead of returningdefaultwhen a key is non-existent / expired.- Parameters
key (str) – The cache key (as a string) to get the value for, e.g.
example:testdefault (Any) – If the cache key
keyisn’t found / is expired, return this value (Default:None)fail (bool) – If set to
True, will raiseCacheNotFoundinstead of returningdefaultwhen a key is non-existent / expired.
- Raises
CacheNotFound – Raised when
fail=Trueandkeywas not found in cache / expired.- Return Any value
The value of the cache key
key, ordefaultif it wasn’t found.