Skip to main content

InMemoryCache

@rotorsoft/act-root


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

Class: InMemoryCache

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

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:25

Parameters

options?
maxSize?

number

Returns

InMemoryCache

Accessors

size

Get Signature

get size(): number

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

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:50

Returns

Promise<void>

Inherit Doc

Implementation of

Cache.clear


dispose()

dispose(): Promise<void>

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

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:30

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:45

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:37

Type Parameters

TState

TState extends Schema

Parameters

stream

string

entry

CacheEntry<TState>

Returns

Promise<void>

Inherit Doc

Implementation of

Cache.set