Skip to Content
HeronJS 3.6 with fully support Typescript 6 is released šŸŽ‰

Stores define shared cache or storage configuration in HeronJS. They are commonly used to register cache backends such as in-memory cache, Redis, Hazelcast, or other supported cache providers.

HeronJS currently focuses on two store types:

  • Cache Store
  • Storage Store as a reserved type for future support

Create a cache store

A store is defined as a configuration object. You register one or more store configurations with @Stores() and then look them up where needed.

export const MemoryCacheConfig = <ModuleStore>{ type: StoreType.CACHE, name: 'memory-cache', isDefault: true, config: <CacheConfig>{ client: CacheClient.MEMORY, config: <MemoryConfig>{ max: 100, ttl: 10, }, }, };

In this configuration:

  • type defines the store category.
  • name is the identifier used for explicit lookup.
  • isDefault marks the store as the default cache store.
  • client selects the cache implementation.
  • config contains provider-specific options.

Register stores

Use @Stores() in the root module to register one or more stores.

@Module({ imports: [TodosModule], }) @Stores([MemoryCacheConfig]) export class AppModule {}

If multiple stores are registered, the one with isDefault: true becomes the primary store used by default lookup.

Look up a cache store

Use @Cache() to inject a registered cache store.

  • @Cache() resolves the default cache store.
  • @Cache('store-name') resolves a named cache store.
@Rest('/todos') export class TodoRest { constructor( private readonly service: TodoService, @Cache() readonly cacheStore: CacheStore, ) {} }

This allows your controllers or providers to reuse the same cache configuration without manually creating cache clients.

Storage stores

Storage Store is reserved for broader storage integrations, but it is not supported in the current version.

For cloud object storage such as Azure, Google Cloud, or AWS, prefer using the official SDK from the provider until HeronJS adds first-class support.

Supported types

  • STORAGE
  • CACHE
Last updated on