@@ -185,17 +185,17 @@ describe.sequential('cache-with-ttl', () => {
185185 } )
186186
187187 it ( 'should fetch again after cache expires' , async ( ) => {
188- // Use longer TTL (200ms) to avoid flaky failures on slow CI runners.
188+ // Use generous TTL to avoid flaky failures on slow CI runners (especially Windows) .
189189 const shortCache = createTtlCache ( {
190- ttl : 200 ,
190+ ttl : 500 ,
191191 prefix : 'short-cache' ,
192192 } )
193193 const fetcher = vi . fn ( async ( ) => 'value' )
194194 await shortCache . getOrFetch ( 'key' , fetcher )
195195 expect ( fetcher ) . toHaveBeenCalledTimes ( 1 )
196196
197- // Wait for TTL to expire (300ms > 200ms TTL).
198- await new Promise ( resolve => setTimeout ( resolve , 300 ) )
197+ // Wait for TTL to expire (700ms > 500ms TTL).
198+ await new Promise ( resolve => setTimeout ( resolve , 700 ) )
199199
200200 await shortCache . getOrFetch ( 'key' , fetcher )
201201 expect ( fetcher ) . toHaveBeenCalledTimes ( 2 )
@@ -327,17 +327,17 @@ describe.sequential('cache-with-ttl', () => {
327327 } )
328328
329329 it ( 'should skip expired entries in getAll' , async ( ) => {
330- // Use longer TTL (200ms) to avoid flaky failures on slow CI runners.
330+ // Use generous TTL to avoid flaky failures on slow CI runners (especially Windows) .
331331 const shortCache = createTtlCache ( {
332- ttl : 200 ,
332+ ttl : 500 ,
333333 prefix : 'expiry-getall-test' ,
334334 } )
335335
336336 await shortCache . set ( 'key1' , 'value1' )
337337 await shortCache . set ( 'key2' , 'value2' )
338338
339- // Wait for TTL to expire (300ms > 200ms TTL).
340- await new Promise ( resolve => setTimeout ( resolve , 300 ) )
339+ // Wait for TTL to expire (700ms > 500ms TTL).
340+ await new Promise ( resolve => setTimeout ( resolve , 700 ) )
341341
342342 const all = await shortCache . getAll < string > ( '*' )
343343 expect ( all . size ) . toBe ( 0 )
@@ -416,18 +416,17 @@ describe.sequential('cache-with-ttl', () => {
416416
417417 describe ( 'TTL expiration' , ( ) => {
418418 it ( 'should expire entries after TTL' , async ( ) => {
419- // Use longer TTL (200ms) to avoid flaky failures on slow CI runners.
420- // Windows in particular can have significant I/O latency during cacache.put().
419+ // Use generous TTL to avoid flaky failures on slow CI runners (especially Windows).
421420 const shortCache = createTtlCache ( {
422- ttl : 200 ,
421+ ttl : 500 ,
423422 prefix : 'expiry-test' ,
424423 } )
425424
426425 await shortCache . set ( 'key' , 'value' )
427426 expect ( await shortCache . get < string > ( 'key' ) ) . toBe ( 'value' )
428427
429- // Wait for TTL to expire (300ms > 200ms TTL).
430- await new Promise ( resolve => setTimeout ( resolve , 300 ) )
428+ // Wait for TTL to expire (700ms > 500ms TTL).
429+ await new Promise ( resolve => setTimeout ( resolve , 700 ) )
431430
432431 expect ( await shortCache . get ( 'key' ) ) . toBeUndefined ( )
433432
@@ -453,16 +452,16 @@ describe.sequential('cache-with-ttl', () => {
453452
454453 it ( 'should refresh TTL on set' , async ( ) => {
455454 const refreshCache = createTtlCache ( {
456- ttl : 300 ,
455+ ttl : 2000 ,
457456 prefix : 'refresh-cache' ,
458457 } )
459458
460459 await refreshCache . set ( 'key' , 'value1' )
461- await new Promise ( resolve => setTimeout ( resolve , 100 ) )
460+ await new Promise ( resolve => setTimeout ( resolve , 200 ) )
462461 await refreshCache . set ( 'key' , 'value2' ) // Refresh TTL
463462
464- await new Promise ( resolve => setTimeout ( resolve , 100 ) )
465- // Should still be cached (100 + 100 = 200ms , but TTL refreshed at 100ms to 300ms )
463+ await new Promise ( resolve => setTimeout ( resolve , 200 ) )
464+ // Should still be cached (200 + 200 = 400ms , but TTL refreshed at 200ms to 2000ms )
466465 expect ( await refreshCache . get < string > ( 'key' ) ) . toBe ( 'value2' )
467466
468467 await refreshCache . clear ( )
0 commit comments