Expand description
§Cache Implementation Details
The cache is implemented as a combination of:
- A
HashMapfor O(1) key lookups - A doubly-linked list for managing the eviction order
- A “visited” flag on each entry to track recent access
When the cache is full and a new item is inserted, the eviction algorithm:
- Starts from the “hand” position (or tail if no hand)
- Finds the first non-visited entry, evicting it
- Marks all visited entries as non-visited while searching