From fbf1846b4dff395d1de6af804c7ed0d6785fccf5 Mon Sep 17 00:00:00 2001 From: harish-berri Date: Fri, 24 Apr 2026 17:20:33 +0000 Subject: [PATCH] refactor(redis): improve documentation for GCPIAMCredentialProvider class Updated the docstring for the GCPIAMCredentialProvider class to clarify its purpose and the caching mechanism for GCP IAM tokens. The changes enhance readability and maintainability by providing a more concise explanation of the token caching strategy and its benefits for Redis authentication. --- litellm/_redis_credential_provider.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/litellm/_redis_credential_provider.py b/litellm/_redis_credential_provider.py index bf9213a11c7..70725fe12c4 100644 --- a/litellm/_redis_credential_provider.py +++ b/litellm/_redis_credential_provider.py @@ -80,16 +80,13 @@ def _get_cached_gcp_iam_token(service_account: str) -> str: class GCPIAMCredentialProvider(CredentialProvider): """ - redis.credentials.CredentialProvider implementation that generates a fresh GCP IAM - token on every new connection. This fixes the 1-hour token expiry issue for async - Redis cluster clients, which previously generated the token once at startup and - cached it as a static password. + redis.credentials.CredentialProvider implementation that supplies GCP IAM tokens + for Redis authentication, with module-level caching per service account. - Tokens are cached at module level per service account for - _GCP_IAM_TOKEN_TTL_SECONDS (55 min) so that repeated connection - establishments — e.g. during connection pool warm-up or health checks — - do not each trigger a synchronous network round-trip that would block - Python's async event loop and cause cascading request latency. + Tokens are cached for _GCP_IAM_TOKEN_TTL_SECONDS (55 min) so that repeated + connection establishments — e.g. during connection pool warm-up or health checks — + do not each trigger a synchronous network round-trip that would block Python's + async event loop and cause cascading request latency. """ def __init__(self, gcp_service_account: str) -> None: