(
value: MapValue<Key, Value, Error>,
ignorePending = false
)
| 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 |
no test coverage detected