( self: ScopedCache<Key, A, E, R>, key: Key, fiber: Fiber.Fiber<any, any>, isRead = true )
| 444 | ) |
| 445 | |
| 446 | const getImpl = <Key, A, E, R>( |
| 447 | self: ScopedCache<Key, A, E, R>, |
| 448 | key: Key, |
| 449 | fiber: Fiber.Fiber<any, any>, |
| 450 | isRead = true |
| 451 | ): Effect.Effect<Entry<A, E> | undefined> => { |
| 452 | if (self.state._tag === "Closed") { |
| 453 | return effect.interrupt |
| 454 | } |
| 455 | const state = self.state |
| 456 | const oentry = MutableHashMap.get(state.map, key) |
| 457 | if (Option.isNone(oentry)) { |
| 458 | return effect.undefined |
| 459 | } else if (hasExpired(oentry.value, fiber)) { |
| 460 | MutableHashMap.remove(state.map, key) |
| 461 | return effect.as( |
| 462 | closeEvicted(oentry.value), |
| 463 | undefined |
| 464 | ) |
| 465 | } else if (isRead) { |
| 466 | MutableHashMap.remove(state.map, key) |
| 467 | MutableHashMap.set(state.map, key, oentry.value) |
| 468 | } |
| 469 | return effect.succeed(oentry.value) |
| 470 | } |
| 471 | |
| 472 | /** |
| 473 | * Retrieves the value associated with the specified key from the cache, only if |
no test coverage detected