Module _cache_implementation

Source
Expand description

§Cache Implementation Details

The cache is implemented as a combination of:

  1. A HashMap for O(1) key lookups
  2. A doubly-linked list for managing the eviction order
  3. A “visited” flag on each entry to track recent access

When the cache is full and a new item is inserted, the eviction algorithm:

  1. Starts from the “hand” position (or tail if no hand)
  2. Finds the first non-visited entry, evicting it
  3. Marks all visited entries as non-visited while searching