Hyperlinkv0.8.0-beta.28

Cache

Cache.getSuccessconsteffect/Cache.ts:598
<Key, A, R>(key: Key): <E>(
  self: Cache<Key, A, E, R>
) => Effect.Effect<Option.Option<A>>
<Key, A, E, R>(self: Cache<Key, A, E, R>, key: Key): Effect.Effect<
  Option.Option<A>
>

Retrieves the value associated with the specified key from the cache, only if it contains a resolved successful value.

Details

This checks only an existing non-expired entry. It returns Option.some when the entry has already resolved successfully, and Option.none for missing, expired, failed, or still-pending entries.

combinatorsgetgetOption
Source effect/Cache.ts:59814 lines
export const getSuccess: {
  <Key, A, R>(key: Key): <E>(self: Cache<Key, A, E, R>) => Effect.Effect<Option.Option<A>>
  <Key, A, E, R>(self: Cache<Key, A, E, R>, key: Key): Effect.Effect<Option.Option<A>>
} = dual(
  2,
  <Key, A, E, R>(self: Cache<Key, A, E, R>, key: Key): Effect.Effect<Option.Option<A>> =>
    core.withFiber((fiber) => {
      const exit = getImpl(self, key, fiber)?.deferred.effect as Exit.Exit<A, E> | undefined
      if (exit && effect.exitIsSuccess(exit)) {
        return effect.succeedSome(exit.value)
      }
      return effect.succeedNone
    })
)