<Key, A, E, R>(self: ScopedCache<Key, A, E, R>): Effect.Effect<Array<A>>Retrieves all successfully cached values from the cache, excluding failed lookups and expired entries.
When to use
Use to inspect currently successful cached values without running cache lookups.
Gotchas
Expired entries are removed and their scopes are closed while filtering.
export const const values: <Key, A, E, R>(
self: ScopedCache<Key, A, E, R>
) => Effect.Effect<Array<A>>
Retrieves all successfully cached values from the cache, excluding failed
lookups and expired entries.
When to use
Use to inspect currently successful cached values without running cache
lookups.
Gotchas
Expired entries are removed and their scopes are closed while filtering.
values = <function (type parameter) Key in <Key, A, E, R>(self: ScopedCache<Key, A, E, R>): Effect.Effect<Array<A>>Key, function (type parameter) A in <Key, A, E, R>(self: ScopedCache<Key, A, E, R>): Effect.Effect<Array<A>>A, function (type parameter) E in <Key, A, E, R>(self: ScopedCache<Key, A, E, R>): Effect.Effect<Array<A>>E, function (type parameter) R in <Key, A, E, R>(self: ScopedCache<Key, A, E, R>): Effect.Effect<Array<A>>R>(self: ScopedCache<Key, A, E, R>(parameter) self: {
state: State<Key, A, E>;
capacity: number;
lookup: (key: Key) => Effect.Effect<A, E, R | Scope.Scope>;
timeToLive: (exit: Exit.Exit<A, E>, key: Key) => Duration.Duration;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
self: interface ScopedCache<in out Key, in out A, in out E = never, out R = never>A scoped cache whose values are acquired by a lookup effect and stored in
per-entry scopes.
When to use
Use to cache values that acquire scoped resources and must release those
resources when entries expire, are evicted, or are invalidated.
Details
Concurrent requests for the same key share the same in-flight lookup.
Entries can expire based on the lookup exit, are evicted when capacity is
exceeded, and release their entry scopes when invalidated, evicted, expired,
or when the cache's owning scope closes.
ScopedCache<function (type parameter) Key in <Key, A, E, R>(self: ScopedCache<Key, A, E, R>): Effect.Effect<Array<A>>Key, function (type parameter) A in <Key, A, E, R>(self: ScopedCache<Key, A, E, R>): Effect.Effect<Array<A>>A, function (type parameter) E in <Key, A, E, R>(self: ScopedCache<Key, A, E, R>): Effect.Effect<Array<A>>E, function (type parameter) R in <Key, A, E, R>(self: ScopedCache<Key, A, E, R>): Effect.Effect<Array<A>>R>): import EffectEffect.interface Effect<out A, out E = never, out R = never>The Effect interface defines a value that lazily describes a workflow or
job. The workflow requires some context R, and may fail with an error of
type E, or succeed with a value of type A.
When to use
Use when you need to represent a lazy, composable workflow that can require
services, fail with a typed error, or succeed with a typed value.
Details
Effect values model resourceful interaction with the outside world,
including synchronous, asynchronous, concurrent, and parallel interaction.
They use a fiber-based concurrency model, with built-in support for
scheduling, fine-grained interruption, structured concurrency, and high
scalability.
To run an Effect value, you need a Runtime, which is a type that is
capable of executing Effect values.
Effect<interface Array<T>Array<function (type parameter) A in <Key, A, E, R>(self: ScopedCache<Key, A, E, R>): Effect.Effect<Array<A>>A>> =>
import effecteffect.const map: {
<A, B>(f: (a: A) => B): <E, R>(
self: Effect.Effect<A, E, R>
) => Effect.Effect<B, E, R>
<A, E, R, B>(
self: Effect.Effect<A, E, R>,
f: (a: A) => B
): Effect.Effect<B, E, R>
}
map(const entries: <Key, A, E, R>(
self: ScopedCache<Key, A, E, R>
) => Effect.Effect<Array<[Key, A]>>
Retrieves all key-value pairs from the cache as an array. This function
only returns entries with successfully resolved values, filtering out any
failed lookups or expired entries.
When to use
Use to inspect the currently successful cached key-value pairs without
running cache lookups.
Gotchas
Expired entries are removed and their scopes are closed while filtering.
entries(self: ScopedCache<Key, A, E, R>(parameter) self: {
state: State<Key, A, E>;
capacity: number;
lookup: (key: Key) => Effect.Effect<A, E, R | Scope.Scope>;
timeToLive: (exit: Exit.Exit<A, E>, key: Key) => Duration.Duration;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
self), import ArrArr.const map: <[Key, A][], A>(f: (a: [Key, A], i: number) => A) => (self: [Key, A][]) => A[] (+1 overload)map(([, value: Avalue]) => value: Avalue))