ScopedCache<Key, A, E, R>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.
export interface 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<in out function (type parameter) Key in ScopedCache<in out Key, in out A, in out E = never, out R = never>Key, in out function (type parameter) A in ScopedCache<in out Key, in out A, in out E = never, out R = never>A, in out function (type parameter) E in ScopedCache<in out Key, in out A, in out E = never, out R = never>E = never, out function (type parameter) R in ScopedCache<in out Key, in out A, in out E = never, out R = never>R = never> extends import PipeablePipeable {
readonly [const TypeId: "~effect/ScopedCache"TypeId]: typeof const TypeId: "~effect/ScopedCache"TypeId
ScopedCache<in out Key, in out A, in out E = never, out R = never>.state: State<Key, A, E>state: type State<K, A, E> =
| {
readonly _tag: "Open"
readonly map: MutableHashMap.MutableHashMap<
K,
Entry<A, E>
>
}
| {
readonly _tag: "Closed"
}
Represents whether a ScopedCache is open or closed.
When to use
Use when inspecting the low-level lifecycle state of a scoped cache.
Details
Open stores cached entries in access order for reuse and eviction.
Closed means the owning scope has closed and the cache can no longer
perform lookup operations.
State<function (type parameter) Key in ScopedCache<in out Key, in out A, in out E = never, out R = never>Key, function (type parameter) A in ScopedCache<in out Key, in out A, in out E = never, out R = never>A, function (type parameter) E in ScopedCache<in out Key, in out A, in out E = never, out R = never>E>
readonly ScopedCache<in out Key, in out A, in out E = never, out R = never>.capacity: numbercapacity: number
readonly ScopedCache<in out Key, in out A, in out E = never, out R = never>.lookup: (key: Key) => Effect.Effect<A, E, R | Scope.Scope>lookup: (key: in out Keykey: function (type parameter) Key in ScopedCache<in out Key, in out A, in out E = never, out R = never>Key) => import EffectEffect.type Effect.Effect = /*unresolved*/ anyEffect<function (type parameter) A in ScopedCache<in out Key, in out A, in out E = never, out R = never>A, function (type parameter) E in ScopedCache<in out Key, in out A, in out E = never, out R = never>E, function (type parameter) R in ScopedCache<in out Key, in out A, in out E = never, out R = never>R | import ScopeScope.type Scope.Scope = /*unresolved*/ anyScope>
readonly ScopedCache<in out Key, in out A, in out E = never, out R = never>.timeToLive: (exit: Exit.Exit<A, E>, key: Key) => Duration.DurationtimeToLive: (exit: Exit.Exit<A, E>exit: import ExitExit.type Exit.Exit = /*unresolved*/ anyExit<function (type parameter) A in ScopedCache<in out Key, in out A, in out E = never, out R = never>A, function (type parameter) E in ScopedCache<in out Key, in out A, in out E = never, out R = never>E>, key: in out Keykey: function (type parameter) Key in ScopedCache<in out Key, in out A, in out E = never, out R = never>Key) => import DurationDuration.type Duration.Duration = /*unresolved*/ anyDuration
}