litellm-mirror/litellm/caching
Krish Dholakia 3a6ba0b955
Litellm perf improvements 3 (#6573)
* perf: move writing key to cache, to background task

* perf(litellm_pre_call_utils.py): add otel tracing for pre-call utils

adds 200ms on calls with pgdb connected

* fix(litellm_pre_call_utils.py'): rename call_type to actual call used

* perf(proxy_server.py): remove db logic from _get_config_from_file

was causing db calls to occur on every llm request, if team_id was set on key

* fix(auth_checks.py): add check for reducing db calls if user/team id does not exist in db

reduces latency/call by ~100ms

* fix(proxy_server.py): minor fix on existing_settings not incl alerting

* fix(exception_mapping_utils.py): map databricks exception string

* fix(auth_checks.py): fix auth check logic

* test: correctly mark flaky test

* fix(utils.py): handle auth token error for tokenizers.from_pretrained
2024-11-05 03:51:26 +05:30
..
__init__.py (testing) add unit tests for LLMCachingHandler Class (#6279) 2024-10-17 19:12:57 +05:30
base_cache.py Litellm dev 10 29 2024 (#6502) 2024-10-29 22:04:16 -07:00
caching.py (perf) Litellm redis router fix - ~100ms improvement (#6483) 2024-10-29 13:58:29 -07:00
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 Litellm perf improvements 3 (#6573) 2024-11-05 03:51:26 +05:30
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 Litellm dev 11 02 2024 (#6561) 2024-11-04 07:48:20 +05:30
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