Software Engineering5.0 · 0 ratings

Caching Strategy Architect

Designs a caching layer with correct invalidation, key design, and consistency guarantees for a given workload.

Role-BasedChain-of-ThoughtStructured-Output

Prompt

ROLE: You are a backend architect who designs caching that speeds things up without serving stale or wrong data.

CONTEXT:
- What needs caching: [DATA/COMPUTATION, READ:WRITE_RATIO, SIZE]
- Freshness tolerance: [HOW_STALE_IS_ACCEPTABLE]
- Infrastructure: [IN-PROCESS / REDIS / CDN / MULTI-TIER]
- Consistency needs: [WHAT_MUST_NEVER_BE_STALE]

TASK (reason through the trade-offs):
1. Decide what to cache and at which layer(s); justify based on access patterns and cost.
2. Design cache keys (namespacing, versioning, parameter inclusion) to avoid collisions and enable targeted invalidation.
3. Choose a write/invalidation strategy (write-through, write-behind, cache-aside, TTL, event-driven) and explain the consistency it yields.
4. Address the hard cases: stampede/thundering herd, cold start, negative caching, and the staleness window.
5. Define eviction policy and a way to observe hit rate and staleness.

OUTPUT FORMAT:
## What & Where to Cache
## Key Design (with examples)
## Invalidation Strategy + Consistency Guarantee
## Edge Cases (stampede, cold start, negative cache)
## Eviction & Observability

CONSTRAINTS:
- Be explicit about the consistency model and the maximum staleness window for each cached item.
- Address cache stampede protection (e.g., locking, request coalescing, jittered TTLs).
- Never cache data whose staleness violates the stated correctness requirements.
- Prefer the simplest strategy that meets the freshness requirement.

How to use this prompt

  1. 1

    Copy the prompt above and paste it into ChatGPT, Claude, or Gemini — or open it in the visual Studio to edit each part on a canvas and run it with your own key.

  2. 2

    Replace any bracketed placeholders with your specifics. The more concrete your context and constraints, the sharper the result — see the 5-part prompt structure.

  3. 3

    Run it, then refine. Ask the model to critique and improve its own answer with self-critique prompting.

Techniques in this prompt

Role-Based

Assigns the model an expert persona so it adopts the right vocabulary, depth, and standards for the task.

Learn this technique
Chain-of-Thought

Asks the model to reason step by step before answering — ideal for multi-step, logical, or analytical tasks.

Learn this technique
Structured Output

Pins the response to a defined structure so it drops straight into your workflow.

Learn this technique

Recommended models

claudegpt-4ogemini

Build on this prompt

Open it in the visual Studio to wire it into a full workflow with your own API key — or learn the craft behind prompts like this.

More in Software Engineering