<!-- Source: https://docs.squirro.com/en/latest/api/squirro.lib.nlp.utils.cache.ExpiringCache.html -->
# ExpiringCache

**`class ExpiringCache(cache_client, check_expired_interval=300, scheduler=None)`**

Bases: [`CacheWithExpiration`](squirro.lib.nlp.utils.cache.CacheWithExpiration.md#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 SummaryMethods SummaryAttributes Documentation

**`SCHEDULER_TASK_PREFIX = 'expiring_cache_task_'`**

Methods Documentation

**`delete(key)`**

Return type

[`None`](https://docs.python.org/3.11/library/constants.html#None)

**`exists(key)`**

Return type

[`bool`](https://docs.python.org/3.11/library/functions.html#bool)

**`expire(key, time)`**

Return type

[`bool`](https://docs.python.org/3.11/library/functions.html#bool)

**`get(key)`**

Return type

[`Optional`](https://docs.python.org/3.11/library/typing.html#typing.Optional)[[`Any`](https://docs.python.org/3.11/library/typing.html#typing.Any)]

**`get_all()`**

Return type

[`list`](https://docs.python.org/3.11/library/stdtypes.html#list)[[`tuple`](https://docs.python.org/3.11/library/stdtypes.html#tuple)[[`str`](https://docs.python.org/3.11/library/stdtypes.html#str), [`Any`](https://docs.python.org/3.11/library/typing.html#typing.Any)]]

**`set(key, value)`**

Return type

[`None`](https://docs.python.org/3.11/library/constants.html#None)
