← Questions

Blocking cache where reads wait for a missing key

0
DatabricksCodingLast asked Jul 2026

Build a keyed cache whose get(key) returns at once when the key is present and otherwise blocks until some thread puts that key. put(key, value) stores or replaces the value and wakes every reader waiting on that key, in the order they started waiting, each seeing the value just put. Implement it with per-key waiting (not one global wake-up), then discuss timeouts on get and what happens to waiters if a key is never written.

Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding