<Key, A, E, R>(self: ScopedCache<Key, A, E, R>): Effect.Effect<number>Retrieves the approximate number of entries in the cache.
When to use
Use to inspect how many entries are currently stored in the scoped cache.
Gotchas
Note that expired entries are counted until they are accessed and removed. The size reflects the current number of entries stored, not the number of valid entries.
export const const size: <Key, A, E, R>(
self: ScopedCache<Key, A, E, R>
) => Effect.Effect<number>
Retrieves the approximate number of entries in the cache.
When to use
Use to inspect how many entries are currently stored in the scoped cache.
Gotchas
Note that expired entries are counted until they are accessed and removed.
The size reflects the current number of entries stored, not the number
of valid entries.
size = <function (type parameter) Key in <Key, A, E, R>(self: ScopedCache<Key, A, E, R>): Effect.Effect<number>Key, function (type parameter) A in <Key, A, E, R>(self: ScopedCache<Key, A, E, R>): Effect.Effect<number>A, function (type parameter) E in <Key, A, E, R>(self: ScopedCache<Key, A, E, R>): Effect.Effect<number>E, function (type parameter) R in <Key, A, E, R>(self: ScopedCache<Key, A, E, R>): Effect.Effect<number>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<number>Key, function (type parameter) A in <Key, A, E, R>(self: ScopedCache<Key, A, E, R>): Effect.Effect<number>A, function (type parameter) E in <Key, A, E, R>(self: ScopedCache<Key, A, E, R>): Effect.Effect<number>E, function (type parameter) R in <Key, A, E, R>(self: ScopedCache<Key, A, E, R>): Effect.Effect<number>R>): import EffectEffect.type Effect.Effect = /*unresolved*/ anyEffect<number> =>
import effecteffect.const sync: <A>(
thunk: LazyArg<A>
) => Effect.Effect<A>
sync(() => 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.ScopedCache<Key, A, E, R>.state: State<Key, A, E>state._tag: "Open" | "Closed"_tag === "Closed" ? 0 : import MutableHashMapMutableHashMap.size(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.ScopedCache<Key, A, E, R>.state: State<Key, A, E>state.map: MutableHashMap.MutableHashMap<
K,
Entry<A, E>
>
(property) map: {
backing: Map<K, V>;
buckets: Map<number, NonEmptyArray<K>>;
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; <…;
toString: () => string;
toJSON: () => unknown;
}
map))