MCPcopy Index your code
hub / github.com/Effect-TS/effect / lookupValueOf

Method lookupValueOf

packages/effect/src/internal/cache.ts:645–682  ·  view source on GitHub ↗
(
    input: Key,
    deferred: Deferred.Deferred<Value, Error>
  )

Source from the content-addressed store, hash-verified

643 }
644
645 lookupValueOf(
646 input: Key,
647 deferred: Deferred.Deferred<Value, Error>
648 ): Effect.Effect<Value, Error> {
649 return effect.clockWith((clock) =>
650 core.suspend(() => {
651 const key = input
652 return pipe(
653 this.lookup(input),
654 core.provideContext(this.context),
655 core.exit,
656 core.flatMap((exit) => {
657 const now = clock.unsafeCurrentTimeMillis()
658 const stats = makeEntryStats(now)
659 const value = complete(
660 makeMapKey(key),
661 exit,
662 stats,
663 now + Duration.toMillis(Duration.decode(this.timeToLive(exit)))
664 )
665 MutableHashMap.set(this.cacheState.map, key, value)
666 return core.zipRight(
667 Deferred.done(deferred, exit),
668 exit
669 )
670 }),
671 core.onInterrupt(() =>
672 core.zipRight(
673 Deferred.interrupt(deferred),
674 core.sync(() => {
675 MutableHashMap.remove(this.cacheState.map, key)
676 })
677 )
678 )
679 )
680 })
681 )
682 }
683}
684
685/** @internal */

Callers 2

getEitherMethod · 0.95
refreshMethod · 0.95

Calls 11

makeEntryStatsFunction · 0.85
makeMapKeyFunction · 0.85
decodeMethod · 0.80
syncMethod · 0.80
pipeFunction · 0.70
completeFunction · 0.70
setMethod · 0.65
doneMethod · 0.65
removeMethod · 0.65
interruptMethod · 0.45

Tested by

no test coverage detected