Overview
Store

Stores are the configuration object for create cache instance of CacheManager (opens in a new tab) like redis, hazelcast or binary

  • Cache Store
  • Storage Store - Not supported in the current version

Cache Store

Create

@Stores accept an Array of stores. The first element of the Array is primary store. The child independent module can use this primary store with StoreType.CACHE or StoreType.STORAGE from StoreType enums.

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

Register

To register a cache store. We just need to import it to Root Module with @Stores

You can provide many cache configs with @Stores. The Store with isDefault value is true is a primary store.

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

Lookup

@CacheLookup is a decorator to find a default cache store. @CacheLookup('store-name') will find a store with the provided name.

@Rest('/todos')
export class TodoRest {
    constructor(private _service: TodoService,@CacheLookup() readonly cacheStore: CacheStore) {}
}

Storage Store


There is a rare chance to support any layer of cloud storage connection. All cloud provider like Azure, Google Cloud Platform or AWS has their SDK for the storage connection. Please consider using these SDK for safety and security.


Supported Types

  • STORAGE
  • CACHE