* fix: Remove unused asyncio import from litellm_logging.py - Fixes F401 linting error blocking CI * fix: Add type ignore comments for MyPy false positives - redis_cache.py: Add type ignore for aclose() - method exists but redis-py type stubs are incomplete - redis_cluster_cache.py: Add type ignore for ping() and aclose() - redis-py typing issue - responses/utils.py: Add type ignore for variable shadowing false positive - transformation.py: Add type ignore for TypedDict expansion - runtime works correctly - aws_secret_manager_v2.py: Add type ignore for dict[str, Any] assignment All changes are safe - code works correctly in runtime, these are MyPy inference limitations. Fixes 7 MyPy errors blocking CI without changing any logic. * fix: Add type ignore for Redis async methods in cache files - Add type: ignore[attr-defined] for aclose() in redis_cache.py - Add type: ignore[attr-defined] for ping() and aclose() in redis_cluster_cache.py - Methods exist but redis-py type stubs are incomplete * refactor: Remove variable shadowing in _transform_response_api_usage_to_chat_usage - Rename parameter 'usage' to 'usage_input' for clarity - Rename local variable 'usage' to 'chat_usage' to avoid shadowing - Eliminates MyPy false positive without needing type: ignore - No functional changes - all tests pass - Improves code readability and type safety |
||
|---|---|---|
| .. | ||
| __init__.py | ||
| _internal_lru_cache.py | ||
| azure_blob_cache.py | ||
| base_cache.py | ||
| caching_handler.py | ||
| caching.py | ||
| disk_cache.py | ||
| dual_cache.py | ||
| gcs_cache.py | ||
| in_memory_cache.py | ||
| llm_caching_handler.py | ||
| qdrant_semantic_cache.py | ||
| Readme.md | ||
| redis_cache.py | ||
| redis_cluster_cache.py | ||
| redis_semantic_cache.py | ||
| s3_cache.py | ||
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:
- RedisCache
- RedisSemanticCache
- QdrantSemanticCache
- InMemoryCache
- DiskCache
- S3Cache
- AzureBlobCache
- 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