← Questions
Find the bugs in a dictionary memoization cache under concurrency
0
I was asked this
No reports yet. Sign in to say where you were asked it.
A slow function is wrapped by a module-level dictionary that stores its results: look up the key, otherwise compute and store. You are shown the code and asked what breaks in production once many threads (or async tasks) call it.
Cover duplicate work when two callers miss at once, races on the dictionary, memory that grows without bound, missing eviction or expiry, and how you would rewrite it to be safe and bounded.
No official answer yet. Write yours on the right and run it.
Nothing published yet.
Sign in to submit your code; every attempt is kept here.
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
