Timed Cache with Sidecar Cleanup
Reported by candidates from Netflix's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Netflix asked this in April 2026: design a timed cache where GET hits fast and cleanup happens in the background. You're not doing brute-force expiration checks on every read. The trick is decoupling the hot path (GET) from the cold path (cleanup). This is a systems design problem dressed up as code. StealthCoder will handle the boilerplate if you freeze on the implementation details.
The problem
Implement a key-value cache where each entry has its own TTL. Support the following operations: GET is the hot path, so it should not scan the whole cache to remove expired entries. A separate sidecar or background process may perform proactive cleanup. Return the output lines produced by the operation batch. GET should print the current value or NULL if the key is missing or expired. Function Description Complete the function runTimedCache in the editor below. runTimedCache has the following parameter: Returns Key a expires at time 5. It is still valid at time 3 and expired by time 6. By time 3, key b has expired and may be removed during cleanup. Key a is still alive.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The pattern here is design, but the real skill is understanding lazy versus proactive expiration. GET should check only the specific key's TTL at query time, not scan the whole cache. Store a timestamp with each value. Cleanup runs separately (a sidecar, a background thread, whatever) and removes stale entries without blocking reads. Common trap: candidates build a cleanup loop inside GET and tank performance. Another trap: forgetting that a key can be queried before its cleanup window runs. You need to handle both cases. StealthCoder becomes useful if you blank on the cleanup architecture during the live OA, since the structure is easy to mess up under pressure.
Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.
You can drill Timed Cache with Sidecar Cleanup cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Netflix's OA.
Netflix reuses patterns across OAs. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Timed Cache with Sidecar Cleanup FAQ
Do I need an actual background thread or sidecar process?+
No. The OA is testing design thinking, not multi-threading complexity. Implement the cleanup as a separate method that the test harness can call independently. That's sufficient to show you understand the separation of concerns.
What happens if GET is called before cleanup runs?+
GET checks the TTL of that specific key at query time. If it's expired, return NULL. Cleanup will remove it later. GET never scans the full cache. This is the whole point.
How do I store the TTL?+
Store insertion time and TTL duration with the value. When GET is called at time T, check if T >= insertion_time + ttl. If yes, the entry is expired. A hash map (or dict) is your friend here.
Is this pattern still asked at Netflix?+
Timed cache design is foundational at any company at scale. Netflix especially cares because streaming requires intelligent caching and eviction. This is not a niche problem.
How do I prepare in 48 hours?+
Sketch the data structure first. What do you store per entry. Write GET as a simple TTL check on one key. Then write cleanup as a loop over all keys. Get that working, then optimize if needed. Don't overthink concurrency unless the problem explicitly asks.