diff --git a/litellm/caching/in_memory_cache.py b/litellm/caching/in_memory_cache.py index 6b40c48c4ef..283eae9a413 100644 --- a/litellm/caching/in_memory_cache.py +++ b/litellm/caching/in_memory_cache.py @@ -293,10 +293,11 @@ 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 - """ - return self.ttl_dict.get(key, None) + """Get the remaining TTL of a key in in-memory cache""" + 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]: """