mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-24 18:24:20 +00:00
Merge 4e07386044
into b82af5b826
This commit is contained in:
commit
e2579f8824
1 changed files with 13 additions and 0 deletions
|
@ -10,6 +10,7 @@ Returns a UserAPIKeyAuth object if the API key is valid
|
|||
import asyncio
|
||||
import re
|
||||
import secrets
|
||||
import time
|
||||
from datetime import datetime, timezone
|
||||
from typing import Optional, cast
|
||||
|
||||
|
@ -553,6 +554,18 @@ async def _user_api_key_auth_builder( # noqa: PLR0915
|
|||
verbose_logger.debug("api key not found in cache.")
|
||||
valid_token = None
|
||||
|
||||
if (
|
||||
valid_token is not None
|
||||
and isinstance(valid_token, UserAPIKeyAuth)
|
||||
and valid_token.last_refreshed_at is not None
|
||||
and user_api_key_cache.default_in_memory_ttl is not None
|
||||
and time.time() - valid_token.last_refreshed_at > user_api_key_cache.default_in_memory_ttl
|
||||
):
|
||||
user_api_key_cache.delete_cache(
|
||||
key=hash_token(api_key)
|
||||
)
|
||||
valid_token = None
|
||||
|
||||
if (
|
||||
valid_token is not None
|
||||
and isinstance(valid_token, UserAPIKeyAuth)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue