Hyperlinkv0.8.0-beta.28

Cache

Cache.valuesconsteffect/Cache.ts:1264
<Key, A, E, R>(self: Cache<Key, A, E, R>): Effect.Effect<Iterable<A>>

Retrieves all successfully cached values from the cache, excluding failed lookups and expired entries.

Example (Reading all cached values)

import { Cache, Effect } from "effect"

const program = Effect.gen(function*() {
  const cache = yield* Cache.make({
    capacity: 10,
    lookup: (key: string) => Effect.succeed(key.length)
  })

  // Add some values to the cache
  yield* Cache.get(cache, "a")
  yield* Cache.get(cache, "ab")
  yield* Cache.get(cache, "abc")

  // Retrieve all cached values
  const values = yield* Cache.values(cache)
  const valuesArray = Array.from(values).sort()

  console.log(valuesArray) // [1, 2, 3]
})
combinators
Source effect/Cache.ts:12642 lines
export const values = <Key, A, E, R>(self: Cache<Key, A, E, R>): Effect.Effect<Iterable<A>> =>
  effect.map(entries(self), Iterable.map(([, value]) => value))