From 0b2c69be64c2c36b898f06139e80807fc7e5faff Mon Sep 17 00:00:00 2001 From: Siraj637909 Date: Tue, 18 Aug 2026 21:31:32 +0530 Subject: [PATCH 1/2] fix(cache): InMemoryCache.async_get_ttl returns remaining seconds, not absolute expiry (gh-37261) Fixes budget_reset_at showing ~57 years in the future when no Redis is configured. InMemoryCache stored absolute expiry timestamps in ttl_dict, but budget_limiter.py adds them directly to datetime.now(). Now async_get_ttl returns remaining seconds like RedisCache does. --- litellm/caching/in_memory_cache.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/litellm/caching/in_memory_cache.py b/litellm/caching/in_memory_cache.py index 38a9966f9f9..3becbaadb9e 100644 --- a/litellm/caching/in_memory_cache.py +++ b/litellm/caching/in_memory_cache.py @@ -264,10 +264,13 @@ class InMemoryCache(BaseCache): self._remove_key(key) async def async_get_ttl(self, key: str) -> int | None: - """ + """Get the remaining TTL of a key in in-memory cache""" Get the remaining TTL of a key in in-memory cache """ - return self.ttl_dict.get(key, None) + expiry = self.ttl_dict.get(key, None) + if expiry is None: + return None + return max(0, expiry - time.time()) async def async_get_oldest_n_keys(self, n: int) -> list[str]: """ From 07396cf07d8f28daa931e23eb926db66f6df6f95 Mon Sep 17 00:00:00 2001 From: Siraj637909 Date: Tue, 18 Aug 2026 21:31:56 +0530 Subject: [PATCH 2/2] fix(cache): clean up duplicate docstring in async_get_ttl --- litellm/caching/in_memory_cache.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/litellm/caching/in_memory_cache.py b/litellm/caching/in_memory_cache.py index 3becbaadb9e..3e00f5df257 100644 --- a/litellm/caching/in_memory_cache.py +++ b/litellm/caching/in_memory_cache.py @@ -265,8 +265,6 @@ class InMemoryCache(BaseCache): async def async_get_ttl(self, key: str) -> int | None: """Get the remaining TTL of a key in in-memory cache""" - Get the remaining TTL of a key in in-memory cache - """ expiry = self.ttl_dict.get(key, None) if expiry is None: return None