Add prompt-caching module: Spring AI 2.1 Anthropic cache strategies on the real request (breakpoints per strategy, hit/miss/write in Usage, one changed word, multi-block system caching, minimum length, 5-minute and 1-hour lifetimes, the 20-block lookback), OpenAI automatic caching with prompt_cache_key, and a cost table. The vendors are a local server applying their documented rules; no vendor API called. Spring Boot 4.2.0, Spring AI 2.1.0, Java 25.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017ic4b4gvXXQgw1eTk5EoTT
This commit is contained in:
Claude
2026-11-24 06:07:23 +05:30
parent 45d83826da
commit 02c3cbf439
32 changed files with 1759 additions and 0 deletions
@@ -0,0 +1,9 @@
# Where each AnthropicCacheStrategy puts cache_control (request: 4 tools, a system prompt, one user turn)
Request shape: tools[0..3], system (one string), messages[0] = retrieved context + question
NONE breakpoints=0 []
TOOLS_ONLY breakpoints=1 [tools[3]] {"type":"ephemeral","ttl":"5m"}
SYSTEM_ONLY breakpoints=1 [system[0]] {"type":"ephemeral","ttl":"5m"}
SYSTEM_AND_TOOLS breakpoints=2 [tools[3], system[0]] {"type":"ephemeral","ttl":"5m"}
CONVERSATION_HISTORY breakpoints=3 [tools[3], system[0], messages[0].content[0]] {"type":"ephemeral","ttl":"5m"}