litellm/tests/test_litellm/caching
Yassin Kortam ae8dc1f39f
fix(proxy): stop stale auth cache re-publish so key updates and deletes propagate across replicas (#33565)
With enable_redis_auth_cache and multiple replicas, /key/update and
/key/delete delete the Redis auth blob and the handling pod's in-memory
entry, but two read-path writers re-published the stale blob from any other
replica's per-pod memory back to Redis with a fresh 60s TTL on every
request: the post-auth re-cache in user_api_key_auth and the spend writeback
in update_cache. Replicas whose in-memory entries expired then re-primed
themselves from the poisoned Redis entry, so key limit and access changes
never took effect fleet-wide while traffic continued, and a deleted key kept
authenticating.

The auth object is now written only by the DB-load paths
(IdentityStore._resolve_key, get_key_object): the post-auth re-cache is
removed outright (even a local-only write could race an invalidation and
resurrect a revoked key on this worker) and spend tracking no longer writes
the auth object back at all; spend is tracked through the spend🔑*
counters. The remaining spend writebacks for user, team, end-user, and tag
objects become local-only so they cannot republish stale management objects
either, with one deliberate exception: the proxy-wide
{litellm_proxy_admin_name}:spend scalar keeps its shared Redis write because
the global max_budget check reads it between authoritative DB reloads, and
it carries no limits or permissions so sharing it cannot resurrect an
invalidated auth blob.

DualCache's redis-to-memory read backfill also ignored default_in_memory_ttl,
pinning backfilled entries for InMemoryCache's 600s default instead of the
configured 60s auth TTL; the backfill now injects the configured default like
every write path already does, so a replica primed from Redis converges
within the auth cache TTL as well.

Consolidates the sibling stale-auth-recache branch; the delete-propagation
case is the duplicate ticket LIT-4350.

Resolves LIT-4219
2026-07-16 15:00:33 -07:00
..
test_azure_blob_cache.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_caching.py feat(caching): add valkey-semantic cache backend and fix semantic cache scope keys (#30675) 2026-06-19 17:09:17 -07:00
test_caching_handler.py fix(logging): stop pinning large request payloads past request end (#33455) 2026-07-15 15:28:37 -07:00
test_check_and_fix_namespace_none_guard.py chore: litellm oss staging160626 (#30527) 2026-06-16 18:23:13 -07:00
test_disk_cache.py chore(lint): zero out crash-class pyright rules and ban new type: ignore comments (#32152) 2026-07-04 16:56:12 -07:00
test_dual_cache.py fix(proxy): stop stale auth cache re-publish so key updates and deletes propagate across replicas (#33565) 2026-07-16 15:00:33 -07:00
test_embedding_router.py chore: litellm oss staging 250626 (#31305) 2026-06-25 21:00:28 -07:00
test_gcs_cache.py chore: litellm oss staging (#30745) 2026-06-18 13:55:35 -07:00
test_in_memory_cache.py fix: prune expired in-memory cache heap entries (#25664) 2026-04-14 23:37:49 +05:30
test_llm_caching_handler.py fix: don't close HTTP/SDK clients on LLMClientCache eviction (#22925) 2026-03-05 12:00:38 -08:00
test_llm_client_cache_e2e.py fix: don't close HTTP/SDK clients on LLMClientCache eviction (#22925) 2026-03-05 12:00:38 -08:00
test_qdrant_semantic_cache.py chore: litellm oss staging 250626 (#31305) 2026-06-25 21:00:28 -07:00
test_redis_cache.py fix(redis): loop-scope async Lua script registration (#31501) 2026-06-27 12:20:40 -07:00
test_redis_cluster_cache.py fix(caching): check REDIS_CLUSTER_NODES env var in Cache and Router class selection (#22790) 2026-03-06 17:31:30 -08:00
test_redis_connection_pool.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_redis_semantic_cache.py chore: litellm oss staging 250626 (#31305) 2026-06-25 21:00:28 -07:00
test_s3_cache.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_valkey_semantic_cache.py fix(caching): pass only metadata to valkey semantic async embedding (#32295) 2026-07-07 08:52:03 +03:00