update_timeout¶
-
abstract async
AsyncCacheAdapter.update_timeout(key: str, timeout: int = 300) → Any[source]¶ Update the timeout for a given
keytodatetime.utcnow() + timedelta(seconds=timeout)This method should accept keys which are already expired, allowing expired cache keys to have their timeout extended after expiry.
Example:
>>> c = CacheAdapter() >>> c.set('example', 'test', timeout=60) >>> sleep(70) >>> c.update_timeout('example', timeout=60) # Reset the timeout for ``'example'`` to ``now + 60 seconds`` >>> c.get('example') 'test'
- Parameters
- Raises
CacheNotFound – Raised when
keywas not found in cache (thus cannot extend timeout)- Return Any value
The value of the cache key