mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-14 23:21:35 +00:00
fix: move TTL global assignments after Cache() succeeds to avoid partial state on failure
This commit is contained in:
parent
d8b80d3ada
commit
afa21f9a0b
1 changed files with 4 additions and 2 deletions
|
|
@ -2796,14 +2796,16 @@ class ProxyConfig:
|
|||
global redis_usage_cache, llm_router
|
||||
from litellm import Cache
|
||||
|
||||
# Construct the cache first; only update global TTL defaults on success
|
||||
# so that a failed initialisation does not leave partial global state.
|
||||
litellm.cache = Cache(**cache_params)
|
||||
|
||||
if "default_in_memory_ttl" in cache_params:
|
||||
litellm.default_in_memory_ttl = cache_params["default_in_memory_ttl"]
|
||||
|
||||
if "default_redis_ttl" in cache_params:
|
||||
litellm.default_redis_ttl = cache_params["default_redis_ttl"]
|
||||
|
||||
litellm.cache = Cache(**cache_params)
|
||||
|
||||
if litellm.cache is not None and isinstance(
|
||||
litellm.cache.cache, (RedisCache, RedisClusterCache)
|
||||
):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue