(item: PoolItem<A, E>)
| 622 | const ttlMillis = Duration.toMillis(Duration.fromInputUnsafe(ttl)) |
| 623 | const creationTimes = new WeakMap<PoolItem<A, E>, number>() |
| 624 | return identity<Strategy<A, E>>({ |
| 625 | run: (pool) => { |
| 626 | const process = (item: PoolItem<A, E>): Effect.Effect<void> => |
| 627 | Effect.suspend(() => { |
| 628 | if (!pool.state.items.has(item) || pool.state.invalidated.has(item)) { |
| 629 | return Effect.void |
| 630 | } |
| 631 | const now = clock.currentTimeMillisUnsafe() |
| 632 | const created = creationTimes.get(item)! |
| 633 | const remaining = ttlMillis - (now - created) |
| 634 | return remaining > 0 |
| 635 | ? Effect.delay(process(item), remaining) |
| 636 | : invalidatePoolItem(pool, item) |
| 637 | }) |
| 638 | return Queue.take(queue).pipe( |
no test coverage detected
searching dependent graphs…