litellm-mirror/litellm/caching
Krish Dholakia 7338b24a74
refactor(redis_cache.py): use a default cache value when writing to r… (#6358)
* refactor(redis_cache.py): use a default cache value when writing to redis

prevent redis from blowing up in high traffic

* refactor(redis_cache.py): refactor all cache writes to use self.get_ttl

ensures default ttl always used when writing to redis

Prevents redis db from blowing up in prod
2024-10-21 16:42:12 -07:00
..
__init__.py (testing) add unit tests for LLMCachingHandler Class (#6279) 2024-10-17 19:12:57 +05:30
base_cache.py refactor(redis_cache.py): use a default cache value when writing to r… (#6358) 2024-10-21 16:42:12 -07:00
caching.py LiteLLM Minor Fixes & Improvements (10/18/2024) (#6320) 2024-10-19 22:23:27 -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 (refactor) - caching use separate files for each cache class (#6251) 2024-10-16 13:17:21 +05:30
dual_cache.py (refactor) - caching use separate files for each cache class (#6251) 2024-10-16 13:17:21 +05:30
in_memory_cache.py (refactor) - caching use separate files for each cache class (#6251) 2024-10-16 13:17:21 +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 refactor(redis_cache.py): use a default cache value when writing to r… (#6358) 2024-10-21 16:42: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