3131 CacheEntryStatus ,
3232 CacheFactory ,
3333 CacheKey ,
34+ CacheProxy ,
3435)
3536from redis .observability .attributes import CSCReason
3637from redis .exceptions import ConnectionError , InvalidResponse , RedisError , TimeoutError
@@ -256,7 +257,9 @@ async def test_async_cache_proxy_signals_evicted_in_progress_fill():
256257
257258
258259async def test_blocking_pool_serializes_cache_owner_checks ():
259- pool = BlockingConnectionPool (max_connections = 1 )
260+ pool = BlockingConnectionPool (
261+ max_connections = 1 , protocol = 3 , cache_config = CacheConfig ()
262+ )
260263 entered = asyncio .Event ()
261264
262265 async def acquire_pool_lock ():
@@ -272,6 +275,41 @@ async def acquire_pool_lock():
272275 await pool .aclose ()
273276
274277
278+ async def test_blocking_pool_skips_lock_without_cache ():
279+ pool = BlockingConnectionPool (max_connections = 1 )
280+ entered = asyncio .Event ()
281+
282+ async def acquire_pool_lock ():
283+ async with pool ._maybe_pool_lock ():
284+ entered .set ()
285+
286+ async with pool ._lock :
287+ task = asyncio .create_task (acquire_pool_lock ())
288+ await asyncio .sleep (0 )
289+ assert entered .is_set () is True
290+
291+ await task
292+ await pool .aclose ()
293+
294+
295+ async def test_async_connection_pool_does_not_double_wrap_custom_cache_factory ():
296+ cache = CacheFactory (CacheConfig ()).get_cache ()
297+ cache_factory = mock .Mock ()
298+ cache_factory .get_cache .return_value = cache
299+ pool = ConnectionPool (
300+ protocol = 3 ,
301+ cache_config = CacheConfig (),
302+ cache_factory = cache_factory ,
303+ )
304+
305+ try :
306+ assert pool .cache is cache
307+ assert isinstance (pool .cache , CacheProxy )
308+ assert not isinstance (pool .cache ._cache , CacheProxy )
309+ finally :
310+ await pool .aclose ()
311+
312+
275313async def test_async_cache_proxy_waits_for_replacement_in_progress_fill ():
276314 connection = mock .Mock ()
277315 connection .can_read = mock .AsyncMock (return_value = False )
0 commit comments