@@ -498,7 +498,11 @@ const runTests = (LRU: typeof LRUCache, t: Test) => {
498498
499499 // advance past the original TTL (80 + 30 = 110 from set, but only 30 from get)
500500 clock . advance ( 30 )
501- t . equal ( c . size , 1 , 'entry survives past original TTL because get refreshed it' )
501+ t . equal (
502+ c . size ,
503+ 1 ,
504+ 'entry survives past original TTL because get refreshed it' ,
505+ )
502506 t . equal ( c . get ( 'a' ) , 1 , 'entry is still retrievable' )
503507
504508 // now let the refreshed TTL expire without any more gets
@@ -511,28 +515,35 @@ const runTests = (LRU: typeof LRUCache, t: Test) => {
511515 t . end ( )
512516 } )
513517
514- t . test ( 'updateAgeOnGet + ttlAutopurge: entry eventually purged if not re-accessed' , t => {
515- const c = new LRU ( {
516- ttl : 50 ,
517- ttlAutopurge : true ,
518- updateAgeOnGet : true ,
519- ttlResolution : 0 ,
520- } )
521- c . set ( 'b' , 2 )
522- t . equal ( c . size , 1 )
523-
524- // access once before TTL expires, refreshing the timer
525- clock . advance ( 30 )
526- t . equal ( c . get ( 'b' ) , 2 , 'alive before TTL' )
527-
528- // do NOT access again — let the refreshed TTL expire
529- // the refreshed TTL starts at t=30, expires at t=30+50+1=81
530- clock . advance ( 52 )
531- t . equal ( c . size , 0 , 'entry autopurged after refreshed TTL with no further access' )
532- t . equal ( c . get ( 'b' ) , undefined , 'entry is gone' )
533-
534- t . end ( )
535- } )
518+ t . test (
519+ 'updateAgeOnGet + ttlAutopurge: entry eventually purged if not re-accessed' ,
520+ t => {
521+ const c = new LRU ( {
522+ ttl : 50 ,
523+ ttlAutopurge : true ,
524+ updateAgeOnGet : true ,
525+ ttlResolution : 0 ,
526+ } )
527+ c . set ( 'b' , 2 )
528+ t . equal ( c . size , 1 )
529+
530+ // access once before TTL expires, refreshing the timer
531+ clock . advance ( 30 )
532+ t . equal ( c . get ( 'b' ) , 2 , 'alive before TTL' )
533+
534+ // do NOT access again — let the refreshed TTL expire
535+ // the refreshed TTL starts at t=30, expires at t=30+50+1=81
536+ clock . advance ( 52 )
537+ t . equal (
538+ c . size ,
539+ 0 ,
540+ 'entry autopurged after refreshed TTL with no further access' ,
541+ )
542+ t . equal ( c . get ( 'b' ) , undefined , 'entry is gone' )
543+
544+ t . end ( )
545+ } ,
546+ )
536547
537548 t . end ( )
538549}
0 commit comments