Code RoomNegative caching for non-existent resources
MediumPrep Room Coding #3437

Negative caching for non-existent resources

System designDistributed systemsMid–Senior~35 min

A public API gets hammered with requests for resources that don't exist — scrapers and a misbehaving client repeatedly request random/deleted IDs. Each 'not found' lookup still queries the database (cache only stores hits), so the miss traffic saturates the DB. Design negative caching for this system: how you cache the absence of a value, how you bound the memory cost when an attacker enumerates infinite non-existent keys, how you avoid serving '404' for a key that gets created moments later, and the security angle.

What a strong answer looks like

Clarify scale and constraints first. Propose a clean component breakdown, then go deep on the hard parts (data model, bottlenecks, consistency, failure modes) and name the trade-offs you are making.

Clarify4:00 left
Estimate4:00 planned
Design11:30 planned
Deep dive9:30 planned
Failure6:00 planned
0:00
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.