@@ -117,7 +117,10 @@ async def test_set_get(self, async_redis_backend: AsyncRedisCacheBackend):
117117 async def test_set_with_ttl (self , async_redis_backend : AsyncRedisCacheBackend ):
118118 value = ETagContent (etag = "test-etag" , content = b"test-content" )
119119 await async_redis_backend .set ("test-key" , value , ttl = 100 )
120- ttl = await async_redis_backend .client .ttl ("test-key" )
120+ # Use _make_key to get the prefixed key
121+ ttl = await async_redis_backend .client .ttl (
122+ async_redis_backend ._make_key ("test-key" )
123+ )
121124 assert ttl > 0 and ttl <= 100
122125
123126 @requires_redis
@@ -139,15 +142,18 @@ async def test_clear(self, async_redis_backend: AsyncRedisCacheBackend):
139142 @requires_redis
140143 async def test_clear_path (self , async_redis_backend : AsyncRedisCacheBackend ):
141144 value = ETagContent (etag = "test-etag" , content = b"test-content" )
142- await async_redis_backend .set ("/users/1" , value )
143- await async_redis_backend .set ("/users/2" , value )
144- await async_redis_backend .set ("/posts/1" , value )
145-
146- cleared = await async_redis_backend .clear_path ("/users/" , include_params = True )
145+ # Use proper cache key format: method:host:path:query_params
146+ # Keys without query params end with empty string after last colon
147+ await async_redis_backend .set ("GET:localhost:/users/1:" , value )
148+ await async_redis_backend .set ("POST:localhost:/users/1:param=1" , value )
149+ await async_redis_backend .set ("GET:localhost:/posts/1:" , value )
150+
151+ # Clear all /users/1 entries regardless of method/params
152+ cleared = await async_redis_backend .clear_path ("/users/1" , include_params = True )
147153 assert cleared == 2
148- assert await async_redis_backend .get ("/users/1" ) is None
149- assert await async_redis_backend .get ("/users/2 " ) is None
150- assert await async_redis_backend .get ("/posts/1" ) == value
154+ assert await async_redis_backend .get ("GET:localhost: /users/1: " ) is None
155+ assert await async_redis_backend .get ("POST:localhost: /users/1:param=1 " ) is None
156+ assert await async_redis_backend .get ("GET:localhost: /posts/1: " ) == value
151157
152158 @requires_redis
153159 async def test_clear_pattern (self , async_redis_backend : AsyncRedisCacheBackend ):
0 commit comments