diff --git a/litellm/caching/in_memory_cache.py b/litellm/caching/in_memory_cache.py index 56c9147e066..1779ea591ca 100644 --- a/litellm/caching/in_memory_cache.py +++ b/litellm/caching/in_memory_cache.py @@ -269,10 +269,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]: """