@@ -213,9 +213,10 @@ public function testRoutingCacheReturnsCachedResultOnRepeat(): void
213213
214214 $ adapter = new TCPAdapter (port: 5432 , resolver: $ resolver );
215215 $ adapter ->setSkipValidation (true );
216+ $ adapter ->setCacheTTL (60 );
216217
217218 // Ensure we are at the start of a fresh second so both calls
218- // land within the same 1-second cache window
219+ // land within the same cache window
219220 $ start = time ();
220221 while (time () === $ start ) {
221222 usleep (1000 );
@@ -246,6 +247,7 @@ public function testCacheInvalidationForcesReResolve(): void
246247
247248 $ adapter = new TCPAdapter (port: 5432 , resolver: $ resolver );
248249 $ adapter ->setSkipValidation (true );
250+ $ adapter ->setCacheTTL (1 );
249251
250252 // Align to second boundary
251253 $ start = time ();
@@ -256,10 +258,9 @@ public function testCacheInvalidationForcesReResolve(): void
256258 $ first = $ adapter ->route ('invaldb ' );
257259 $ this ->assertFalse ($ first ->metadata ['cached ' ]);
258260
259- // Invalidate the resolver cache
260261 $ resolver ->purge ('invaldb ' );
261262
262- // Wait for the routing table cache to expire (1 second TTL)
263+ // Wait for the routing table cache to expire
263264 sleep (2 );
264265
265266 $ second = $ adapter ->route ('invaldb ' );
@@ -318,19 +319,18 @@ public function testConcurrentResolutionOfMultipleDatabases(): void
318319
319320 $ adapter = new TCPAdapter (port: 5432 , resolver: $ resolver );
320321 $ adapter ->setSkipValidation (true );
322+ $ adapter ->setCacheTTL (60 );
321323
322324 $ results = [];
323325 for ($ i = 1 ; $ i <= $ databaseCount ; $ i ++) {
324326 $ results [$ i ] = $ adapter ->route ("concurrent {$ i }" );
325327 }
326328
327- // Verify each database resolved to its correct endpoint
328329 for ($ i = 1 ; $ i <= $ databaseCount ; $ i ++) {
329330 $ this ->assertSame ("10.0.10. {$ i }:5432 " , $ results [$ i ]->endpoint );
330331 $ this ->assertSame (Protocol::PostgreSQL, $ results [$ i ]->protocol );
331332 }
332333
333- // All should have been cache misses (first resolution)
334334 $ stats = $ adapter ->getStats ();
335335 $ this ->assertSame ($ databaseCount , $ stats ['cacheMisses ' ]);
336336 $ this ->assertSame (0 , $ stats ['cacheHits ' ]);
0 commit comments