( self: ScopedCache<Key, A, E, R>, key: Key, fiber: Fiber.Fiber<any, any>, isRead = true )
| 357 | ) |
| 358 | |
| 359 | const getImpl = <Key, A, E, R>( |
| 360 | self: ScopedCache<Key, A, E, R>, |
| 361 | key: Key, |
| 362 | fiber: Fiber.Fiber<any, any>, |
| 363 | isRead = true |
| 364 | ): Effect.Effect<Entry<A, E> | undefined> => { |
| 365 | if (self.state._tag === "Closed") { |
| 366 | return effect.interrupt |
| 367 | } |
| 368 | const state = self.state |
| 369 | const oentry = MutableHashMap.get(state.map, key) |
| 370 | if (Option.isNone(oentry)) { |
| 371 | return effect.undefined |
| 372 | } else if (hasExpired(oentry.value, fiber)) { |
| 373 | MutableHashMap.remove(state.map, key) |
| 374 | return effect.as( |
| 375 | Scope.close(oentry.value.scope, effect.exitVoid), |
| 376 | undefined |
| 377 | ) |
| 378 | } else if (isRead) { |
| 379 | MutableHashMap.remove(state.map, key) |
| 380 | MutableHashMap.set(state.map, key, oentry.value) |
| 381 | } |
| 382 | return effect.succeed(oentry.value) |
| 383 | } |
| 384 | |
| 385 | /** |
| 386 | * Retrieves the value associated with the specified key from the cache, only if |
no test coverage detected