mirror of
https://github.com/Zygo/bees.git
synced 2025-05-18 13:55:44 +02:00
We need a better cache expiration algorithm than "make a copy of the entire thing, sort it while holding a lock, and delete half the items in a single burst." Replace the Lamport clock with a double-linked list. Each insert or lookup operation moves the affected item to the head of the list. Each erase operation deletes one single item at the tail of the list. Also sort out some iterator invalidation nonsense by doing erases before inserts instead of "insert, erase, find the inserted item again because we invalidated the found iterator during the erase." The new implementation adds a second word-sized member to each Value as well as a copy of the Key. Hopefully the enlarged size is not a deal-breaker. Signed-off-by: Zygo Blaxell <bees@furryterror.org>