(
input: Key,
deferred: Deferred.Deferred<Value, Error>
)
| 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 */ |
no test coverage detected