litellm-mirror/litellm/caching
Krish Dholakia 4f8a3fd4cf
redis otel tracing + async support for latency routing (#6452)
* docs(exception_mapping.md): add missing exception types

Fixes https://github.com/Aider-AI/aider/issues/2120#issuecomment-2438971183

* fix(main.py): register custom model pricing with specific key

Ensure custom model pricing is registered to the specific model+provider key combination

* test: make testing more robust for custom pricing

* fix(redis_cache.py): instrument otel logging for sync redis calls

ensures complete coverage for all redis cache calls

* refactor: pass parent_otel_span for redis caching calls in router

allows for more observability into what calls are causing latency issues

* test: update tests with new params

* refactor: ensure e2e otel tracing for router

* refactor(router.py): add more otel tracing acrosss router

catch all latency issues for router requests

* fix: fix linting error

* fix(router.py): fix linting error

* fix: fix test

* test: fix tests

* fix(dual_cache.py): pass ttl to redis cache

* fix: fix param
2024-10-28 21:52:12 -07:00
..
__init__.py (testing) add unit tests for LLMCachingHandler Class (#6279) 2024-10-17 19:12:57 +05:30
base_cache.py redis otel tracing + async support for latency routing (#6452) 2024-10-28 21:52:12 -07:00
caching.py fix linting - remove # noqa PLR0915 from fixed function 2024-10-23 23:36:39 +05:30
caching_handler.py (refactor) get_cache_key to be under 100 LOC function (#6327) 2024-10-19 15:21:11 +05:30
disk_cache.py redis otel tracing + async support for latency routing (#6452) 2024-10-28 21:52:12 -07:00
dual_cache.py redis otel tracing + async support for latency routing (#6452) 2024-10-28 21:52:12 -07:00
in_memory_cache.py (Testing) Add unit testing for DualCache - ensure in memory cache is used when expected (#6471) 2024-10-29 08:42:57 +05:30
qdrant_semantic_cache.py (code quality) add ruff check PLR0915 for too-many-statements (#6309) 2024-10-18 15:36:49 +05:30
Readme.md (refactor) - caching use separate files for each cache class (#6251) 2024-10-16 13:17:21 +05:30
redis_cache.py redis otel tracing + async support for latency routing (#6452) 2024-10-28 21:52:12 -07:00
redis_semantic_cache.py (refactor) - caching use separate files for each cache class (#6251) 2024-10-16 13:17:21 +05:30
s3_cache.py (refactor) - caching use separate files for each cache class (#6251) 2024-10-16 13:17:21 +05:30

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. 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