mirror of
https://github.com/tiennm99/litellm.git
synced 2026-08-05 12:23:28 +00:00
(fix) improve proxy api_key caching
This commit is contained in:
@@ -528,10 +528,9 @@ async def user_api_key_auth(
|
||||
|
||||
# Token passed all checks
|
||||
api_key = valid_token.token
|
||||
hashed_token = hash_token(api_key)
|
||||
|
||||
# Add hashed token to cache
|
||||
user_api_key_cache.set_cache(key=hashed_token, value=valid_token, ttl=60)
|
||||
user_api_key_cache.set_cache(key=api_key, value=valid_token, ttl=60)
|
||||
valid_token_dict = _get_pydantic_json_dict(valid_token)
|
||||
valid_token_dict.pop("token", None)
|
||||
"""
|
||||
@@ -1455,6 +1454,7 @@ async def generate_key_helper_fn(
|
||||
saved_token["expires"] = saved_token["expires"].isoformat()
|
||||
if key_data["token"] is not None and isinstance(key_data["token"], str):
|
||||
hashed_token = hash_token(key_data["token"])
|
||||
saved_token["token"] = hashed_token
|
||||
user_api_key_cache.set_cache(
|
||||
key=hashed_token,
|
||||
value=LiteLLM_VerificationToken(**saved_token), # type: ignore
|
||||
|
||||
Reference in New Issue
Block a user