My first instinct was LRU cache and I basically started coding before fully thinking through the size-based eviction.
Start by clarifying requirements and constraints, then propose a design using a hash map for O(1) lookups and a doubly linked list for LRU eviction. Discuss trade-offs between eviction policies and concurrency, and outline the implementation details for put, get, and update operations.
Pro tip: Emphasize the importance of handling edge cases like updating an existing dataset with a larger size that triggers eviction, and discuss how to make the design thread-safe for concurrent access.
Ask about expected dataset sizes, access patterns, eviction policy preferences, and concurrency requirements to tailor the design.
Propose using a hash map for O(1) access and a doubly linked list to track usage order for LRU eviction, ensuring efficient updates and evictions.
Explain how put handles updates (adjust size, update order) and evictions (remove LRU until space), and how get updates recency.
Discuss alternative eviction policies (LFU, FIFO), concurrency strategies (locking, sharding), and potential optimizations like lazy eviction.
Mention testing scenarios: updating with larger size, evicting multiple items, concurrent access, and handling datasets larger than capacity.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.