( self: Effect.Effect<A, E, R>, timeToLive: Duration.DurationInput, cache: Synchronized.SynchronizedRef<Option.Option<readonly [number, Deferred.Deferred<A, E>]>> )
| 275 | |
| 276 | /** @internal */ |
| 277 | const getCachedValue = <A, E, R>( |
| 278 | self: Effect.Effect<A, E, R>, |
| 279 | timeToLive: Duration.DurationInput, |
| 280 | cache: Synchronized.SynchronizedRef<Option.Option<readonly [number, Deferred.Deferred<A, E>]>> |
| 281 | ): Effect.Effect<A, E, R> => |
| 282 | core.uninterruptibleMask((restore) => |
| 283 | pipe( |
| 284 | effect.clockWith((clock) => clock.currentTimeMillis), |
| 285 | core.flatMap((time) => |
| 286 | updateSomeAndGetEffectSynchronized(cache, (option) => { |
| 287 | switch (option._tag) { |
| 288 | case "None": { |
| 289 | return Option.some(computeCachedValue(self, timeToLive, time)) |
| 290 | } |
| 291 | case "Some": { |
| 292 | const [end] = option.value |
| 293 | return end - time <= 0 |
| 294 | ? Option.some(computeCachedValue(self, timeToLive, time)) |
| 295 | : Option.none() |
| 296 | } |
| 297 | } |
| 298 | }) |
| 299 | ), |
| 300 | core.flatMap((option) => |
| 301 | Option.isNone(option) ? |
| 302 | core.dieMessage( |
| 303 | "BUG: Effect.cachedInvalidate - please report an issue at https://github.com/Effect-TS/effect/issues" |
| 304 | ) : |
| 305 | restore(core.deferredAwait(option.value[1])) |
| 306 | ) |
| 307 | ) |
| 308 | ) |
| 309 | |
| 310 | /** @internal */ |
| 311 | const invalidateCache = <A, E>( |
no test coverage detected