mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-12 08:42:18 +00:00
* fix(spend): respect use_redis_transaction_buffer when selecting the SpendLogs ledger * revert: keep the SpendLogs ledger independent of use_redis_transaction_buffer Measured on a live proxy, ledger on and ledger off grow RSS at the same rate per request, so gating the ledger on the Redis buffer moved deployments off it without fixing the growth. * fix(redis): free each request's Redis batch scope once the request ends The native request batch keeps a copy of the context it is built in. It was built inside the request scope, so that context pointed back at the scope, and the cycle collector cannot see through the native object. Every request's batches, spend counter batches and native Redis state stayed alive, growing worker RSS about 40 KiB per request and slowing each request as the heap grew. Build the native batch in the context the scope was opened from instead. |
||
|---|---|---|
| .. | ||
| __init__.py | ||
| _embedding_router.py | ||
| _internal_lru_cache.py | ||
| affinity_cache.py | ||
| azure_blob_cache.py | ||
| base_cache.py | ||
| caching.py | ||
| caching_handler.py | ||
| dual_cache.py | ||
| evicted_client_closer.py | ||
| gcs_cache.py | ||
| in_memory_cache.py | ||
| llm_caching_handler.py | ||
| qdrant_semantic_cache.py | ||
| Readme.md | ||
| redis_batch.py | ||
| redis_cache.py | ||
| redis_cluster_cache.py | ||
| redis_cluster_node_isolation.py | ||
| redis_semantic_cache.py | ||
| s3_cache.py | ||
| valkey_semantic_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
- S3Cache
- AzureBlobCache
- DualCache (updates both Redis and an in-memory cache simultaneously)
Folder Structure
litellm/caching/
├── base_cache.py
├── caching.py
├── caching_handler.py
├── dual_cache.py
├── in_memory_cache.py
├── qdrant_semantic_cache.py
├── redis_cache.py
├── redis_semantic_cache.py
├── s3_cache.py