Skip to content

CacheExtension

Defined in: src/cache/CacheExtension.ts:18

System-wide registry for named caches. Apps that need more than one cache (e.g. a Redis-backed response cache and a separate Memcached idempotency-store) register each one under a stable name and look it up via system.extension(CacheExtensionId).cache(name).

The default cache is always available and starts as an InMemoryCache — handy for tests and dev. Registering a different factory under 'default' (or selecting via the HOCON path actor-ts.cache.default.plugin) replaces it.

new CacheExtension(system): CacheExtension

Defined in: src/cache/CacheExtension.ts:22

ActorSystem

CacheExtension

cache(name?): Cache

Defined in: src/cache/CacheExtension.ts:46

Resolve a cache by name. Names map to plugin ids via the HOCON path actor-ts.cache.<name>.plugin. Unknown names fall back to the in-memory plugin so callers always get something — handy for tests where config wiring would be busywork.

string = 'default'

Cache


close(): Promise<void>

Defined in: src/cache/CacheExtension.ts:63

Best-effort close of every instantiated cache.

Promise<void>


registerCache(pluginId, factory): void

Defined in: src/cache/CacheExtension.ts:32

Register a cache factory under pluginId. The factory runs lazily on the first cache(name) call that resolves to this plugin via config. Re-registering the same id replaces the factory and forces a re-instantiation on next access.

string

(system) => Cache

void


setCache(name, cache): void

Defined in: src/cache/CacheExtension.ts:58

Replace the cache instance for name directly — useful for tests.

string

Cache

void