L4 · Medium
LRU Cache System
Problem
Design an in-memory cache system with LRU eviction policy, TTL support, and thread safety.
Requirements
- Get and Set operations with O(1) complexity
- LRU eviction when capacity is full
- TTL (time-to-live) per key
- Evict expired entries automatically
- Support cache statistics: hits, misses, evictions
- Thread-safe operations
Constraints
- –Configurable max capacity
- –TTL precision: seconds
- –Zero TTL means no expiration
✓ Saved