cachetools.cachelru

CacheLRU contains maximum size items

Eviction policy:

    evict TTL-ed entry (if TTL enabled), otherwise
    if oldest entry not expired - evict oldest accessed (LRU)

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

More...

Members

Classes

CacheLRU
class CacheLRU(K, V, Allocator = Mallocator)

Detailed Description

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.

Meta