Module cachetools.cachelru

CacheLRU contains maximum size items

Eviction policy:

User can be informed about evicted entries via cache event list.

Implemented as HashMap and multi-dlist.

HashMap keeps

  1. cached value.
  2. pointer to dlist element.
  3. creation time (to check expiration and purge expired entry on get() without access to dlist).

dlist keep key, creation timestamp (to check expiration)

  1. key, so that we can remove entries from hashmap for lists heads (AccessIndex and TimeIndex)
  2. creation time, so that we can check expiration for 'TimeIndex'
Each element in dlist have two sets of double-links - first set create order by access time, second set for creation time.

Classes

NameDescription
CacheLRU