<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.type Effect.Effect = /*unresolved*/ anyEffect<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.map(([, value: anyvalue]) => value: anyvalue))