litellm/tests/integration/caching
ryan-crabbe-berri cae28c5515
perf(caching): hash response cache keys piece by piece and store under the looked-up key (#52267)
* test(caching): pin response cache keys and cover large image and clamped max_tokens requests

Pins the cache key to the sha256 of the same formatted request text it has always
used, caps memory while hashing a request full of large images, and checks that a
repeat of a request whose max_tokens LiteLLM lowered is served from the cache on
async, sync and no-cache paths and through the proxy.

* perf(caching): hash cache keys piece by piece and reuse the lookup key on every write

Requests carrying large base64 images no longer build the whole request as one
string to hash it. Only the parts holding a large string are walked, so small
requests stay at C speed, and the hashed bytes are unchanged so existing cache
entries and the Rust cache reader keep hitting.

The key is computed once before max_tokens is clamped (async, sync, and when the
read is skipped via no-cache), and every cache write reuses it, so a clamped
request is stored under the key its identical repeat looks up.

* fix(caching): drop a comment that restated the cache check and measure only the key's own memory in the test

* test(code-quality): allow the depth-capped cache key walkers in the recursion detector
2026-11-17 15:58:07 -08:00
..
response_cache_case.py fix(caching): keep reasoning, citations, and audio on streamed cache hits (#32096) 2026-10-29 10:08:12 -07:00
test_cache_max_messages.py test(integration): look up owned cache keys and clean up sweep models (#47255) 2026-10-18 10:27:53 +00:00
test_embedding_file_block_cache.py feat(gemini): accept file content blocks with video_metadata on multimodal embeddings (#45305) 2026-10-08 13:20:03 -07:00
test_evicted_client_closer_real_io.py ci(unit): cut unit check time with cheaper per-test resets and fewer non-unit tests (#51864) 2026-11-14 15:41:30 -08:00
test_in_memory_cache_heap_bound.py fix(router): keep the prompt caching affinity pin alive as long as the prefix's cache_control ttl (#46084) 2026-10-14 21:10:09 -07:00
test_prompt_cache_alert_streaks_real_io.py feat(alerts): report observed Anthropic cache misses as advisories (#51973) 2026-11-16 15:36:07 -08:00
test_redis_cache_non_tls_ssl_settings.py fix(redis): drop ssl_ kwargs from the async pool when ssl is off (#52344) 2026-11-17 13:23:34 -08:00
test_response_cache_chaos.py test(integration): give each owned proxy a private database and Redis by default (#47213) 2026-10-18 03:37:41 +00:00
test_response_cache_empty_output.py test: update the spend tests that still expected the pre-ledger accounting queues (#50814) 2026-11-09 22:07:42 -08:00
test_response_cache_large_payload_key.py perf(caching): hash response cache keys piece by piece and store under the looked-up key (#52267) 2026-11-17 15:58:07 -08:00
test_response_cache_model_group_key.py fix(caching): read the cache key's model group from the router's metadata for the call (#48917) 2026-10-29 05:35:23 -07:00
test_response_cache_stream_replay.py fix(caching): keep reasoning, citations, and audio on streamed cache hits (#32096) 2026-10-29 10:08:12 -07:00
test_valkey_semantic_cache_real_io.py ci(unit): cut unit check time with cheaper per-test resets and fewer non-unit tests (#51864) 2026-11-14 15:41:30 -08:00