Thanks, and agreed on the two-user test. It's cheap, and it catches the bugs that TTL tuning only hides. On the stampede question: when the data changes every few seconds, I lean towards background refresh before expiry rather than the lock. With a TTL that short, the lock path gets taken constantly, so every expiry produces a small burst of waiting requests (or stale reads), and the lock key itself turns into a hot key. Refreshing ahead from a single worker keeps the hot keys warm, readers almost never see a miss, and your staleness bound is simply the refresh interval, which is easy to reason about. Two caveats from doing it in practice: Only refresh keys that are actually hot. Refreshing everything ahead of time wastes work on keys nobody reads, so we track recent access and refresh only those keys. Probabilistic early expiry (a request near the end of the TTL occasionally volunteers to recompute) gets you most of the benefit without a separate worker. Keep the single-rebuild lock as the fallback for cold keys and for the moments when the refresher falls behind. And if the data changes every second or two and readers need it exact, it's worth asking whether it belongs in a TTL cache at all. Pushing updates on write (pub/sub or change events) is often simpler than fighting the race.
