Qikuyueser.com

Check a Cache for Staleness Bugs

Added 2026-11-03

Caching is not just TTL; it is also read-after-write and invalidation order.

Here is a cache design or code. Check: 1) whether TTL matches how often the data changes; 2) whether read-after-write can return the old value; 3) invalidation versus update ordering and the intermediate state; 4) consistency across multiple instances; 5) a minimal protection against cache stampede; 6) the staleness risk most easily missed.
Site original

Chinese original

Open in ChatGPT
How to use

缓存 bug 的典型形状:数据已经改了,用户还看到旧的。

Try tweaking it

  • Have it restate requirements and constraints before writing code.
  • Ask for the smallest change plus a rollback path, not a full-file rewrite.

What you should get

  • A minimal, runnable change with copy-ready code
  • Impact list: which files and call sites must follow

Common mistakes

  • Asking it to touch ten files at once, then losing track of what broke what.
  • Pasting only the error, with no code or version, and getting an unfixable answer.

How to check the output

  • The change runs, can be rolled back, and touches nothing unrelated.
  • Edge cases (empty, oversized, concurrent) are covered or explained.

Where it works

  • Good for: having it restate requirements and constraints, then propose the smallest runnable change.
  • Watch out: include versions and a minimal reproduction with the error, or the fix may look plausible but not fit.

Included in

More in this topic