Design a Cache with Pluggable Eviction
Medium · Low-Level Design · about 40 minutes
Asked at Microsoft, Amazon, Salesforce, HubSpot, Epic Games.
Design an in-memory key-value cache with a fixed capacity. get and put should be O(1). The eviction policy must be pluggable: LRU, LFU and FIFO, chosen when the cache is created. Entries can also have a time-to-live after which they read as missing.