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:
@@ -0,0 +1,14 @@
|
||||
# A cache hit in Spring AI's Usage, and what one changed word costs (SYSTEM_AND_TOOLS, 4 tools, 24,000-character system prompt)
|
||||
|
||||
A. The same tools and system prompt, a different question each time
|
||||
call 1 getPromptTokens=6959 getCacheReadInputTokens=0 getCacheWriteInputTokens=6628
|
||||
call 2 getPromptTokens=6957 getCacheReadInputTokens=6628 getCacheWriteInputTokens=0
|
||||
call 2: 6628 of 6957 prompt tokens came from the cache; 329 were billed at the plain input price
|
||||
(getPromptTokens() includes the cached tokens in 2.1.0)
|
||||
|
||||
B. After a warm-up call, what does each change do? (read = served from cache, write = stored again)
|
||||
(the four tool definitions alone are 550 tokens; the whole prefix is 6628)
|
||||
nothing changed read=6628 write=0 uncached=326
|
||||
only the retrieved context changed read=6628 write=0 uncached=1007
|
||||
one word of the system prompt changed read=550 write=6079 uncached=12
|
||||
one word of one tool description changed read=0 write=6628 uncached=12
|
||||
Reference in New Issue
Block a user