FanoutCache.expire()
Remove every expired entry from every shard, and its value file, as Cache.expire does.
Usage
FanoutCache.expire(
*,
timeout=None,
)Parameters
timeout: float | None = None- Seconds the whole call may spend waiting for write locks (another thread’s or another process’s) or a pending fork, across every shard, for this call only (default: the cache’s timeout). It bounds waiting, not work: a chunk already running finishes, and once it’s spent, each remaining chunk still gets one try with no wait, so shards no one else is writing are all done even at a short timeout.
Returns
int- How many entries were removed.
Raises
Timeout-
Some shard stayed locked past timeout; the others were still done. It carries
removedandfailed_shards(see the class docs), as any failure here does, underdurable=Truetoo.
Examples
try:
cache.expire(timeout=5.0)
except Timeout as exc:
exc.failed_shards, exc.removed # which shards were skipped, and how many entries went anyway