mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 18:54:30 +00:00
(fix) improve proxy api_key caching
This commit is contained in:
parent
ae95e4c3f9
commit
cfec3c611e
1 changed files with 2 additions and 2 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue