Hyperlinkv0.8.0-beta.28

ScopedCache

ScopedCache.hasconsteffect/ScopedCache.ts:499
<Key, A>(key: Key): <E, R>(
  self: ScopedCache<Key, A, E, R>
) => Effect.Effect<boolean>
<Key, A, E, R>(
  self: ScopedCache<Key, A, E, R>,
  key: Key
): Effect.Effect<boolean>

Checks whether the cache contains an entry for the specified key.

When to use

Use to test whether an unexpired entry exists for a key without running the cache lookup.

Details

This does not start lookups and does not refresh access order. Expired entries are treated as absent and their scopes are closed while checking. If the cache is closed, the effect is interrupted.

combinatorsgetOptionget
export const has: {
  <Key, A>(key: Key): <E, R>(self: ScopedCache<Key, A, E, R>) => Effect.Effect<boolean>
  <Key, A, E, R>(self: ScopedCache<Key, A, E, R>, key: Key): Effect.Effect<boolean>
} = dual(
  2,
  <Key, A, E>(self: ScopedCache<Key, A, E>, key: Key): Effect.Effect<boolean> =>
    effect.uninterruptible(
      core.withFiber((fiber) => effect.map(getImpl(self, key, fiber, false), Predicate.isNotUndefined))
    )
)