Loading the puzzle…
The puzzle IDE is built for a laptop or larger screen. You can read everything here, but selecting code is easier with a mouse and a wider window.
Interview question: design a client-side cache for API responses that keeps an entry for a grace period after its last user goes away, and then frees it.
In RTK Query this is buildCacheCollectionHandler in
packages/toolkit/src/query/core/buildMiddleware/cacheCollection.ts. A query's
only subscriber unsubscribes, and keepUnusedDataFor is 60 seconds for that
endpoint. 30 seconds later a new component subscribes to the same query, with
the same cache key, and stays subscribed. What happens to the cache entry at
the 60-second mark? Select one option.
One of the listed options.
Each hint revealed before you solve takes 20 points off this puzzle's score.
Solve this puzzle to see the solution and a full explanation.
Pick one of the options.