Prompt that protects caches from concurrent recomputation with coalescing and staggered expiry. Paste it into an AI tool of your choice, which then guards the cache against stampede.
Results depend on the tool, the model and what you enter.
Fill in
What you type stays in this browser window. We store and send nothing.
Which cache?
local process cache
distributed cache
CDN or edge cache
HTTP cache in front of the API
mixed
What fills the cache?
database query
call to another service
heavy computation
file or object storage
mixed
What do you see?
origin overloaded after expiry
latency spikes on the hour
many identical computations in parallel
nothing yet, prevention
new spikes after a deploy
Your prompt
Help me protect a cache so an expired entry is not recomputed by many requests at the same time.
Cache: [Cache]
Origin: [Origin]
Symptom: [Symptom]
Steps: 1. Read the cache keys, expiry settings and the code that calls the origin on a miss. 2. Check whether each miss recomputes on its own or concurrent requests are coalesced. 3. Propose a short lock or coalescing per key, with expiry if the computing run crashes. 4. Decide whether stale entries may still be served briefly while a refresh runs in the background. 5. Check whether all entries expire in the same second and propose staggered expiry. 6. Name metrics and alerts for hit rate, origin load and wait time.
Output: current state, coalescing design, rule for stale entries, expiry proposal and alerts.
Take particular care to coalesce concurrent recomputations and do not let the origin collapse under an empty cache.
Before you answer, check: Are all instructions met? If key information is missing or a placeholder in square brackets is still in the text, ask instead of guessing. Mark assumptions as assumptions.
You have edited the prompt. Changes in the fields above no longer overwrite it.
This is an instruction for an AI, not the result itself.
Fill in the fields or tap a suggestion. Leave out names, addresses and other personal data.
Copy the finished prompt into an AI tool of your choice.
Paste cache configuration, the miss-path code and metrics for hit rate and origin load, without real customer data.
Why does this work?
When a popular entry expires, hundreds of requests often hit the database at once. Without coalescing, load multiplies exactly when the cache is empty.
Tips
Test coalescing and briefly serving stale values under artificial load on a test system first.
Prompt that plans a data backfill in small, resumable batches with clear brakes.
Prompt · Intermediate · about 15 min
You may use our prompts freely, including at work. Please do not republish them as your own collection. We give no warranty for AI results; check them yourself. Terms of use