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

Method resolveMapValue

packages/effect/src/internal/cache.ts:565–601  ·  view source on GitHub ↗
(
    value: MapValue<Key, Value, Error>,
    ignorePending = false
  )

Source from the content-addressed store, hash-verified

563 }
564
565 resolveMapValue(
566 value: MapValue<Key, Value, Error>,
567 ignorePending = false
568 ): Effect.Effect<Option.Option<Value>, Error> {
569 return effect.clockWith((clock) => {
570 switch (value._tag) {
571 case "Complete": {
572 this.trackAccess(value.key)
573 if (this.hasExpired(clock, value.timeToLiveMillis)) {
574 MutableHashMap.remove(this.cacheState.map, value.key.current)
575 return core.succeed(Option.none<Value>())
576 }
577 this.trackHit()
578 return core.map(value.exit, Option.some)
579 }
580 case "Pending": {
581 this.trackAccess(value.key)
582 this.trackHit()
583 if (ignorePending) {
584 return core.succeed(Option.none<Value>())
585 }
586 return core.map(Deferred.await(value.deferred), Option.some)
587 }
588 case "Refreshing": {
589 this.trackAccess(value.complete.key)
590 this.trackHit()
591 if (this.hasExpired(clock, value.complete.timeToLiveMillis)) {
592 if (ignorePending) {
593 return core.succeed(Option.none<Value>())
594 }
595 return core.map(Deferred.await(value.deferred), Option.some)
596 }
597 return core.map(value.complete.exit, Option.some)
598 }
599 }
600 })
601 }
602
603 trackHit(): void {
604 this.cacheState.hits = this.cacheState.hits + 1

Callers 3

getOptionMethod · 0.95
getOptionCompleteMethod · 0.95
getEitherMethod · 0.95

Calls 6

trackAccessMethod · 0.95
hasExpiredMethod · 0.95
trackHitMethod · 0.95
removeMethod · 0.65
mapMethod · 0.65
awaitMethod · 0.45

Tested by

no test coverage detected