Hyperlinkv0.8.0-beta.28

Cache

Cache.invalidateAllconsteffect/Cache.ts:1143
<Key, A, E, R>(self: Cache<Key, A, E, R>): Effect.Effect<void>

Invalidates all entries in the cache.

Example (Invalidating all entries)

import { Cache, Effect } from "effect"

// Clear all cached entries at once
const program = Effect.gen(function*() {
  const cache = yield* Cache.make({
    capacity: 10,
    lookup: (key: string) => Effect.succeed(key.length)
  })

  // Populate cache with multiple entries
  yield* Cache.get(cache, "apple")
  yield* Cache.get(cache, "banana")
  yield* Cache.get(cache, "cherry")

  console.log(yield* Cache.size(cache)) // 3
  console.log(yield* Cache.has(cache, "apple")) // true

  // Clear all entries
  yield* Cache.invalidateAll(cache)

  // Verify cache is empty
  console.log(yield* Cache.size(cache)) // 0
  console.log(yield* Cache.has(cache, "apple")) // false
  console.log(yield* Cache.has(cache, "banana")) // false
  console.log(yield* Cache.has(cache, "cherry")) // false
})
combinators
Source effect/Cache.ts:11434 lines
export const invalidateAll = <Key, A, E, R>(self: Cache<Key, A, E, R>): Effect.Effect<void> =>
  effect.sync(() => {
    MutableHashMap.clear(self.map)
  })