All challenges
Code AnalysisHard 60s

Cache stampede on expiry

What failure mode does this pattern create under high concurrency?
Starter code
val = cache.get(key)
if val is None:
    val = db.query("SELECT ... slow")   # 2s
    cache.set(key, val, ttl=60)
return val

Think you can answer under pressure?

Get matched and answer live questions in 3-minute 1v1 battles. Elo ranking, badge tiers and bragging rights on the line.

Play this in a 3-minute battle