Hyperlinkv0.8.0-beta.28

ScopedCache

ScopedCache.sizeconsteffect/ScopedCache.ts:719
<Key, A, E, R>(self: ScopedCache<Key, A, E, R>): Effect.Effect<number>

Retrieves the approximate number of entries in the cache.

When to use

Use to inspect how many entries are currently stored in the scoped cache.

Gotchas

Note that expired entries are counted until they are accessed and removed. The size reflects the current number of entries stored, not the number of valid entries.

combinators
export const size = <Key, A, E, R>(self: ScopedCache<Key, A, E, R>): Effect.Effect<number> =>
  effect.sync(() => self.state._tag === "Closed" ? 0 : MutableHashMap.size(self.state.map))