litellm/tests/unit/caching
Yujong Lee 14d50599fa feat(redis): move the v3 rate limiter keyspace onto the Rust store
The limiter's keys ({descriptor:value}:requests, :tokens, :window and the
:max_parallel_requests gauge), its eight Lua scripts and its memory tier now
live in litellm-redis-store (rate_limits.rs). The scripts are byte for byte
main's, so both stacks share one script SHA during a rolling deploy.

The Python limiter keeps its admission logic and talks to a thin store in
litellm/redis/stores/rate_limits.py with domain ids (RateLimitScope,
RateLimitCounter) instead of key strings. Inside a request scope its
scripts ride the request's native pre-call batch, so the first admission
script and the armed cooldown read go out in one pipeline. Post-call token
scripts, window-guarded settlements, slot releases and refund increments
ride the native post-call batch, and their fallbacks run once it settles.
The batch and dynamic limiters read and write the keyspace through the
same store.

Rust tests run every script against real Redis, standalone and cluster,
including over-limit, refunds, gauge slot expiry and cross-slot behavior.
Matching inline wire cases are checked from both sides.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

The limiter sends the commands main does. Counter reads, slot acquire, count
and the pre-response release are direct EVALSHA calls with the counter-read
groups one after another, window-guarded token adjusts run one by one on their
own trips, plain increments are INCRBYFLOAT with EXPIRE, and an increment
without a TTL takes RedisCache.default_ttl like async_increment.
2026-11-05 13:26:41 +09:00
..
__init__.py
_event_loop_reuse.py fix(caching): key cached async clients by a per-loop token instead of id(loop) (#48877) 2026-10-29 13:14:48 -07:00
test_azure_blob_cache.py test: move tests/test_litellm core utils, routing, responses, caching and rust_bridge into tests/unit (#43199) 2026-09-25 17:10:13 -07:00
test_cache_preset_key.py
test_caching.py feat(hosted_vllm)!: keep vLLM's stop_reason and token_ids on chat choices and stream chunks (#48393) 2026-11-02 13:26:29 -08:00
test_caching_handler.py test(caching): assert sync cache-hit logging without depending on thread order (#47093) 2026-10-17 14:00:03 -07:00
test_check_and_fix_namespace_none_guard.py test: move tests/test_litellm core utils, routing, responses, caching and rust_bridge into tests/unit (#43199) 2026-09-25 17:10:13 -07:00
test_dual_cache.py fix(caching): make Redis Cluster commands wait for a pool slot instead of tripping the circuit breaker (#46488) 2026-10-14 15:27:00 -07:00
test_embedding_router.py refactor(router): move router callers onto the entry points and invert the proxy imports (#48847) 2026-10-29 17:26:33 +00:00
test_evicted_client_closer.py fix(caching): key cached async clients by a per-loop token instead of id(loop) (#48877) 2026-10-29 13:14:48 -07:00
test_gcs_cache.py test: migrate legacy unit dirs and unrun folders into tests/unit, tests/integration and tests/e2e (#45940) 2026-10-11 06:24:57 -07:00
test_in_memory_cache.py feat(router): add deployment rpd and tpd daily limits to enforce_model_rate_limits (#48875) 2026-10-28 15:52:44 -07:00
test_llm_caching_handler.py fix(caching): key cached async clients by a per-loop token instead of id(loop) (#48877) 2026-10-29 13:14:48 -07:00
test_llm_client_cache_e2e.py test: move tests/test_litellm core utils, routing, responses, caching and rust_bridge into tests/unit (#43199) 2026-09-25 17:10:13 -07:00
test_qdrant_semantic_cache.py refactor(router): move router callers onto the entry points and invert the proxy imports (#48847) 2026-10-29 17:26:33 +00:00
test_redis_batch.py feat(redis): run router cooldowns and usage on the Rust store 2026-11-05 13:26:07 +09:00
test_redis_cache.py test(caching): baseline breaker metrics from live state after gc (#46652) 2026-10-15 05:53:30 -07:00
test_redis_cluster_cache.py fix(caching): make Redis Cluster commands wait for a pool slot instead of tripping the circuit breaker (#46488) 2026-10-14 15:27:00 -07:00
test_redis_cluster_node_isolation.py test: move tests/test_litellm core utils, routing, responses, caching and rust_bridge into tests/unit (#43199) 2026-09-25 17:10:13 -07:00
test_redis_connection_pool.py test: move tests/test_litellm core utils, routing, responses, caching and rust_bridge into tests/unit (#43199) 2026-09-25 17:10:13 -07:00
test_redis_semantic_cache.py refactor(router): move router callers onto the entry points and invert the proxy imports (#48847) 2026-10-29 17:26:33 +00:00
test_request_redis_batch_post_call.py feat(redis): move the v3 rate limiter keyspace onto the Rust store 2026-11-05 13:26:41 +09:00
test_request_redis_batch_pre_call.py feat(redis): move the v3 rate limiter keyspace onto the Rust store 2026-11-05 13:26:41 +09:00
test_responses_stream_cache_keys.py refactor: expose core private helpers under public names (#44871) 2026-10-07 00:05:27 +00:00
test_s3_cache.py test: move routing, caching and callback tests out of local_testing (#45761) 2026-10-10 09:33:09 -07:00
test_unit_test_caching.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_valkey_semantic_cache.py test: move tests/test_litellm core utils, routing, responses, caching and rust_bridge into tests/unit (#43199) 2026-09-25 17:10:13 -07:00