@@ -2980,7 +2980,20 @@ export const make = Effect.gen(function* () {
29802980 } ,
29812981 {
29822982 capacity : DETAIL_CACHE_CAPACITY ,
2983- timeToLive : ( exit ) => ( Exit . isSuccess ( exit ) ? CHECKS_CACHE_TTL : Duration . zero ) ,
2983+ // Expire from the read's start so checks seeded from a slow detail read keep their age.
2984+ timeToLive : ( exit ) =>
2985+ ! Exit . isSuccess ( exit )
2986+ ? Duration . zero
2987+ : exit . value === null
2988+ ? CHECKS_CACHE_TTL
2989+ : Duration . millis (
2990+ Math . max (
2991+ 0 ,
2992+ exit . value . observedAt +
2993+ Duration . toMillis ( CHECKS_CACHE_TTL ) -
2994+ clock . currentTimeMillisUnsafe ( ) ,
2995+ ) ,
2996+ ) ,
29842997 } ,
29852998 ) ;
29862999
@@ -3014,12 +3027,10 @@ export const make = Effect.gen(function* () {
30143027 return detailUncached ( refOfCacheKey ( key ) ) . pipe (
30153028 Effect . tap (
30163029 Effect . fn ( "PullRequestService.recordDetailStats" ) ( function * ( value : PullRequestDetail ) {
3017- // GitHub detail includes the same checks; seed only fresh reads at their shorter TTL.
3018- const now = yield * Clock . currentTimeMillis ;
3030+ // GitHub detail includes the same checks; the checks TTL counts from their observation.
30193031 if (
30203032 value . provider === "github" &&
30213033 value . observedAt !== undefined &&
3022- now - value . observedAt < Duration . toMillis ( CHECKS_CACHE_TTL ) &&
30233034 ! ( yield * Cache . has ( checksCache , key ) )
30243035 ) {
30253036 yield * Cache . set ( checksCache , key , {
@@ -3037,7 +3048,7 @@ export const make = Effect.gen(function* () {
30373048 additions : value . additions ,
30383049 deletions : value . deletions ,
30393050 } ,
3040- now ,
3051+ yield * Clock . currentTimeMillis ,
30413052 ) ;
30423053 } ) ,
30433054 ) ,
0 commit comments