Back to problems

Implement a Key-Value Cache with Per-Entry Expiration

Object-Oriented Programming · Netflix · Medium

Byte-Limited Cache with Per-Entry Expiration and Oldest-Live Eviction Design Overview This cache tracks both expiration order and replacement order in addition to a primary key lookup. The core idea is to keep a hash map for O(1) key access, a min-heap for expiring entries by absolute deadline, and another min-heap for evicting the oldest live entry. I define replacement age as a monotonically increasing birthVersion assigned whenever an entry is inserted or overwritten. An…

Checking your access…