diff --git a/google/cloud/alloydbconnector/connector.py b/google/cloud/alloydbconnector/connector.py index 9a108164..0b100a82 100644 --- a/google/cloud/alloydbconnector/connector.py +++ b/google/cloud/alloydbconnector/connector.py @@ -37,6 +37,7 @@ from google.cloud.alloydbconnector.instance import RefreshAheadCache from google.cloud.alloydbconnector.lazy import LazyRefreshCache import google.cloud.alloydbconnector.pg8000 as pg8000 +from google.cloud.alloydbconnector.static import StaticConnectionInfoCache from google.cloud.alloydbconnector.types import CacheTypes from google.cloud.alloydbconnector.utils import generate_keys from google.cloud.alloydbconnector.utils import strip_http_prefix @@ -188,6 +189,8 @@ async def connect_async(self, instance_uri: str, driver: str, **kwargs: Any) -> # use existing connection info if possible if instance_uri in self._cache: cache = self._cache[instance_uri] + elif self._static_conn_info: + cache = StaticConnectionInfoCache(instance_uri, self._static_conn_info) else: if self._refresh_strategy == RefreshStrategy.LAZY: logger.debug( diff --git a/tests/unit/test_connector.py b/tests/unit/test_connector.py index 11f6b237..349120c6 100644 --- a/tests/unit/test_connector.py +++ b/tests/unit/test_connector.py @@ -321,6 +321,8 @@ def test_Connector_static_connection_info( ) # check connection is returned assert connection is True + # check that cache is not set + assert fake_client.instance.uri() not in connector._cache def test_connect_when_closed(credentials: FakeCredentials) -> None: