litellm/litellm/caching
Shivam Rawat ed66ee312c
fix(caching): pass only metadata to valkey semantic async embedding (#32295)
* fix(caching): pass only metadata to valkey semantic async embedding

ValkeySemanticCache async get/set passed **kwargs into _get_async_embedding,
which raised TypeError on cache_key and other fields and silently skipped
all cache writes. Match redis-semantic by forwarding metadata only.

Co-authored-by: Cursor <cursoragent@cursor.com>

* test(caching): add async_get_cache embedding call regression test

Mirror the async_set_cache spy test so async_get_cache passing **kwargs
into _get_async_embedding is caught by a real signature, not AsyncMock.

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Shivam Rawat <shivamrawat@Shivams-MacBook-Pro.local>
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-07 08:52:03 +03:00
..
__init__.py Add GCS bucket caching support (#13122) 2025-08-04 16:09:33 -07:00
_embedding_router.py style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
_internal_lru_cache.py (litellm SDK perf improvements) - handle cases when unable to lookup model in model cost map (#7750) 2025-01-13 19:58:46 -08:00
azure_blob_cache.py style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
base_cache.py style: run black formatter on entire codebase 2026-03-11 17:07:57 -03:00
caching.py style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
caching_handler.py style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
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
dual_cache.py style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
gcs_cache.py style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
in_memory_cache.py style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
llm_caching_handler.py fix: don't close HTTP/SDK clients on LLMClientCache eviction (#22925) 2026-03-05 12:00:38 -08:00
qdrant_semantic_cache.py style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
Readme.md add azure blob cache support (#12587) 2025-07-15 11:47:38 -07:00
redis_cache.py style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
redis_cluster_cache.py style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
redis_semantic_cache.py style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
s3_cache.py style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
valkey_semantic_cache.py fix(caching): pass only metadata to valkey semantic async embedding (#32295) 2026-07-07 08:52:03 +03: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