litellm/litellm/caching
Mateo Wang c3222ec110
Merge pull request #41171 from BerriAI/litellm_converted_stream_spend_tracking
fix(logging): track spend for streams a deployment hook converted to non-streaming
2026-09-15 15:34:13 -07:00
..
__init__.py refactor(lint): apply every safe ruff autofix and zero 28 strict-rule budgets 2026-08-01 15:43:29 -07:00
_embedding_router.py fix(caching): bound the semantic cache embedding lookup 2026-08-20 16:09:30 -07:00
_internal_lru_cache.py feat(lint): enforce Final on locals and freeze function parameters (LIT010, LIT011) 2026-08-04 12:54:39 -07:00
affinity_cache.py fix(router): preserve session model choice within each complexity tier 2026-09-15 00:09:17 -07:00
azure_blob_cache.py feat(lint): enforce Final on locals and freeze function parameters (LIT010, LIT011) 2026-08-04 12:54:39 -07:00
base_cache.py chore(lint): clear grandfathered over-limit lint drift and ratchet budgets down 2026-08-05 12:18:13 -07:00
caching.py fix(caching): keep generic add_cache failures at ERROR unless the backend is Redis 2026-09-14 19:59:10 +00:00
caching_handler.py fix(caching): replay agentic loop follow-up cache hits as plain objects 2026-09-15 08:35:13 +00:00
disk_cache.py chore(lint): clear grandfathered over-limit lint drift and ratchet budgets down 2026-08-05 12:18:13 -07:00
dual_cache.py feat(proxy): make the in-memory management cache capacity configurable (#40725) 2026-09-11 09:55:30 -07:00
evicted_client_closer.py fix(caching): clear strict-lint budget breaches in re-landed closer code 2026-08-05 11:08:19 -07:00
gcs_cache.py feat(lint): enforce Final on locals and freeze function parameters (LIT010, LIT011) 2026-08-04 12:54:39 -07:00
in_memory_cache.py refactor(mcp): reuse in-memory discovery storage 2026-09-11 17:53:51 -07:00
llm_caching_handler.py fix(caching): clear strict-lint budget breaches in re-landed closer code 2026-08-05 11:08:19 -07:00
qdrant_semantic_cache.py fix(proxy): run the remaining inline token counts off the event loop 2026-09-08 18:42:38 +00:00
Readme.md add azure blob cache support (#12587) 2025-07-15 11:47:38 -07:00
redis_cache.py fix(redis): route the per-TTL pipeline write timeout log through the shared throttle 2026-09-14 19:38:14 +00:00
redis_cluster_cache.py fix(redis): support credential providers across clients 2026-08-24 19:07:13 -04:00
redis_cluster_node_isolation.py fix(caching): keep a node timeout from forcing a cluster-wide topology reinit on redis-py 8.x (#39349) 2026-09-03 17:31:58 -07:00
redis_semantic_cache.py fix(proxy): run the remaining inline token counts off the event loop 2026-09-08 18:42:38 +00:00
s3_cache.py chore(lint): strip inert type: ignore comments and zero LIT009, LIT010, LIT011 headroom 2026-08-05 02:37:24 -07:00
valkey_semantic_cache.py chore(lint): fix post-merge type regressions and ratchet lint budgets 2026-08-29 20:16:04 +00:00

Caching on LiteLLM

LiteLLM supports multiple caching mechanisms. This allows users to choose the most suitable caching solution for their use case.

The following caching mechanisms are supported:

  1. RedisCache
  2. RedisSemanticCache
  3. QdrantSemanticCache
  4. InMemoryCache
  5. DiskCache
  6. S3Cache
  7. AzureBlobCache
  8. DualCache (updates both Redis and an in-memory cache simultaneously)

Folder Structure

litellm/caching/
├── base_cache.py
├── caching.py
├── caching_handler.py
├── disk_cache.py
├── dual_cache.py
├── in_memory_cache.py
├── qdrant_semantic_cache.py
├── redis_cache.py
├── redis_semantic_cache.py
├── s3_cache.py

Documentation