All challenges
Code AnalysisHard 60s

Thundering herd with negative result

This endpoint is called for user-supplied IDs, some nonexistent. What is the failure?
Starter code
def get_profile(pid):
    p = cache.get(pid)
    if p is None:
        p = db.query("SELECT ... WHERE id=?", pid)  # returns None for bad ids
        if p is not None:
            cache.set(pid, p, 60)
    return p

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