Company: kAIgentic-SDE_25may
Difficulty: medium
In-Memory Cache with Eviction Policies Problem Statement Design and implement a generic in-memory cache system with pluggable eviction policies. Your implementation should demonstrate: Clean interface design and separation of concerns Support for multiple eviction strategies (LRU and LFU) Proper use of object-oriented principles Requirements Part 1: Core Cache Interface Implement a Cache interface/protocol with the following operations: get(key) - Retrieve a value by key. Returns None/nil if not found. put(key, value) - Store a key-value pair. If cache is full, evict based on policy. delete(key) - Remove a key-value pair. size() - Return current number of items in cache. clear() - Remove all items from cache. Part 2: Eviction Policies Implement two eviction policies: LRU (Least Recently Used): Evict the item that was accessed (get/put) longest ago. LFU (Least Frequently Used): Evict the item that was accessed the fewest times. If there's a tie, evict the least recently used among them.