TTL-Aware LRU Cache for Security Master Lookups
Last updated: November 29, 2026
Quick Overview
Implement a bounded in-process cache for security reference data lookups that evicts the least recently used entry when full and treats entries older than a TTL as misses, with O(1) get and put.
Point72
November 29, 20260
0
0 solved
Implement a bounded in-process cache for security reference data lookups that evicts the least recently used entry when full and treats entries older than a TTL as misses, with O(1) get and put.
Research and trading services at Point72 hit the security master constantly to map tickers to identifiers, sectors, and lot sizes, and that data changes on corporate actions. The interviewer is looking at memory bounds, data structure choice for O(1) operations, and whether you think about staleness and testability (an injectable clock) rather than only the happy path.
What the Interviewer Expects
- Choose a hash map plus recency order (OrderedDict or dict plus doubly linked list)
- Bound memory by entry count and explain how to bound by bytes instead
- Expire lazily on read and prefer evicting expired entries when full
- Inject the clock so TTL behaviour is testable without sleeping
- Expose hit, miss, and eviction counters for tuning
Key Topics to Cover
How to Approach This
- Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
- Choose data structures based on access patterns, not familiarity.
- Prefer immutable data and message passing over shared mutable state for concurrency.
- Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
- How would you make this safe for many threads, and would you shard the lock?
- How do you avoid a stampede when a hot ticker expires and 200 requests miss at once?
- How would you invalidate entries when a corporate action event arrives instead of waiting for the TTL?
- When is an LFU or a size-aware policy better than LRU here?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice System Design ProblemsSample Answer
Requirements
get(key) returns the value if present and fresh, otherwise a default. put(key, value) inserts or refreshes. At most capacity entries. Each entry expires ttl seconds after its last put. Both op...
High-Level Design
An OrderedDict gives a hash lookup and a recency list in one structure: move_to_end on a hit, popitem(last=False) for the LRU. Each value stores its expiry time. Expiry is lazy: a read that find...