ExpiringCache

class squirro.lib.nlp.utils.cache.ExpiringCache(cache_client, check_expired_interval=300, scheduler=None)

Bases: squirro.lib.nlp.utils.cache.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

SCHEDULER_TASK_PREFIX

Methods Summary

delete(key)

rtype

None

exists(key)

rtype

bool

expire(key, time)

rtype

bool

get(key)

rtype

Optional[Any]

get_all()

rtype

List[Tuple[str, Any]]

set(key, value)

rtype

None

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