ExpiringCache#

class ExpiringCache(cache_client, check_expired_interval=300, scheduler=None)#

Bases: CacheWithExpiration

Wrapper for the cache client to implement keys expiration.

Every time the cache is touched (set, get, delete, exists, expire) it checks for expired keys and clean them. The cleaning doesn’t run more often than specified in the check_expired_interval parameter.

Scheduler parameter may be provided to register the cleaning task to the scheduler.

Attributes Summary

Methods Summary

delete(key)

exists(key)

expire(key, time)

get(key)

get_all()

set(key, value)

Attributes Documentation

SCHEDULER_TASK_PREFIX = 'expiring_cache_task_'#

Methods Documentation

delete(key)#
Return type:

None

exists(key)#
Return type:

bool

expire(key, time)#
Return type:

bool

get(key)#
Return type:

Optional[Any]

get_all()#
Return type:

List[Tuple[str, Any]]

set(key, value)#
Return type:

None