Skip to main content
Version: Current

InMemoryCache

@rotorsoft/act-root


@rotorsoft/act-root / act/src / InMemoryCache

Class: InMemoryCache

Defined in: libs/act/src/adapters/in-memory-cache.ts:18

In-memory LRU cache for stream snapshots.

Backed by an internal LruMap for O(1) get/set with LRU eviction. Configurable maxSize bounds memory usage.

Example​

import { cache } from "@rotorsoft/act";
import { InMemoryCache } from "@rotorsoft/act";

cache(new InMemoryCache({ maxSize: 500 }));

Implements​

Constructors​

Constructor​

new InMemoryCache(options?): InMemoryCache

Defined in: libs/act/src/adapters/in-memory-cache.ts:24

Parameters​

options?​
maxSize?​

number

Returns​

InMemoryCache

Accessors​

size​

Get Signature​

get size(): number

Defined in: libs/act/src/adapters/in-memory-cache.ts:59

Current number of entries held by the LRU.

Returns​

number

Methods​

clear()​

clear(): Promise<void>

Defined in: libs/act/src/adapters/in-memory-cache.ts:49

Returns​

Promise<void>

Inherit Doc​

Implementation of​

Cache.clear


dispose()​

dispose(): Promise<void>

Defined in: libs/act/src/adapters/in-memory-cache.ts:54

Returns​

Promise<void>

Inherit Doc​

Implementation of​

Cache.dispose


get()​

get<TState>(stream): Promise<CacheEntry<TState> | undefined>

Defined in: libs/act/src/adapters/in-memory-cache.ts:29

Type Parameters​

TState​

TState extends Schema

Parameters​

stream​

string

Returns​

Promise<CacheEntry<TState> | undefined>

Inherit Doc​

Implementation of​

Cache.get


invalidate()​

invalidate(stream): Promise<void>

Defined in: libs/act/src/adapters/in-memory-cache.ts:44

Parameters​

stream​

string

Returns​

Promise<void>

Inherit Doc​

Implementation of​

Cache.invalidate


set()​

set<TState>(stream, entry): Promise<void>

Defined in: libs/act/src/adapters/in-memory-cache.ts:36

Type Parameters​

TState​

TState extends Schema

Parameters​

stream​

string

entry​

CacheEntry<TState>

Returns​

Promise<void>

Inherit Doc​

Implementation of​

Cache.set