State<K, A, E>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.
export type 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) K in type State<K, A, E>K, function (type parameter) A in type State<K, A, E>A, function (type parameter) E in type State<K, A, E>E> = {
readonly _tag: "Open"_tag: "Open"
readonly 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: import MutableHashMapMutableHashMap.interface MutableHashMap<out K, out V>A mutable hash map that stores key-value pairs and supports both referential
and Effect structural equality.
When to use
Use as a mutable key-value map when in-place updates are acceptable and keys
may rely on Effect structural equality.
Details
Operations mutate the map in place. Keys that implement Equal / Hash can
be looked up structurally; other keys use normal JavaScript reference or
primitive equality.
Example (Using a mutable hash map)
import { MutableHashMap } from "effect"
// Create a mutable hash map with string keys and number values
const map: MutableHashMap.MutableHashMap<string, number> = MutableHashMap
.empty()
// Add some data
MutableHashMap.set(map, "count", 42)
MutableHashMap.set(map, "total", 100)
// Use as iterable
for (const [key, value] of map) {
console.log(`${key}: ${value}`)
}
// Output:
// count: 42
// total: 100
// Convert to array
const entries = Array.from(map)
console.log(entries) // [["count", 42], ["total", 100]]
MutableHashMap<function (type parameter) K in type State<K, A, E>K, interface Entry<A, E>A single scoped cache entry.
When to use
Use when inspecting the open state of a ScopedCache and you need the stored
deferred result, entry scope, or expiration timestamp for a key.
Details
The entry contains the deferred lookup result shared by readers, the scope
that owns resources acquired while computing the value, and an optional
expiration time in milliseconds. Removing the entry closes its scope.
Entry<function (type parameter) A in type State<K, A, E>A, function (type parameter) E in type State<K, A, E>E>>
} | {
readonly _tag: "Closed"_tag: "Closed"
}