Stores
Stores declare cache resources owned by the application. 4.0.0 supports memory, Redis and disk cache implementations. Hazelcast is declared in the enum but is not implemented; storage-store declarations are rejected.
import 'reflect-metadata';
import {Module, Stores, StoreType, CacheClient, type ModuleStore} from '@heronjs/common';
export const memoryCache: ModuleStore = {
type: StoreType.CACHE,
name: 'memory-cache',
isDefault: true,
config: {client: CacheClient.MEMORY, config: {max: 100, ttl: 60000}},
};
@Module({})
@Stores([memoryCache])
export class AppModule {}Use isDefault: true for the store used by default cache behavior. Cache managers use Keyv, whose TTL is in milliseconds. CacheStore.get() returns the manager if available; handle the optional result before using it.
The application registers cache resources in its container and owns disconnection. await app.close() waits for cleanup. See Caching for route caching and eviction.
Last updated on