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