UNPKG

2.05 kBTypeScriptView Raw
1import { ModuleMetadata, Provider, Type } from '../../interfaces';
2import { CacheManagerOptions } from './cache-manager.interface';
3export declare type CacheModuleOptions<StoreConfig extends Record<any, any> = Record<string, any>> = CacheManagerOptions & StoreConfig & {
4 /**
5 * If "true', register `CacheModule` as a global module.
6 */
7 isGlobal?: boolean;
8};
9/**
10 * Interface describing a `CacheOptionsFactory`. Providers supplying configuration
11 * options for the Cache module must implement this interface.
12 *
13 * @see [Async configuration](https://docs.nestjs.com/techniques/caching#async-configuration)
14 *
15 * @publicApi
16 */
17export interface CacheOptionsFactory<StoreConfig extends Record<any, any> = Record<string, any>> {
18 createCacheOptions(): Promise<CacheModuleOptions<StoreConfig>> | CacheModuleOptions<StoreConfig>;
19}
20/**
21 * Options for dynamically configuring the Cache module.
22 *
23 * @see [Async configuration](https://docs.nestjs.com/techniques/caching#async-configuration)
24 *
25 * @publicApi
26 */
27export interface CacheModuleAsyncOptions<StoreConfig extends Record<any, any> = Record<string, any>> extends Pick<ModuleMetadata, 'imports'> {
28 /**
29 * Injection token resolving to an existing provider. The provider must implement
30 * the `CacheOptionsFactory` interface.
31 */
32 useExisting?: Type<CacheOptionsFactory<StoreConfig>>;
33 /**
34 * Injection token resolving to a class that will be instantiated as a provider.
35 * The class must implement the `CacheOptionsFactory` interface.
36 */
37 useClass?: Type<CacheOptionsFactory<StoreConfig>>;
38 /**
39 * Function returning options (or a Promise resolving to options) to configure the
40 * cache module.
41 */
42 useFactory?: (...args: any[]) => Promise<CacheModuleOptions<StoreConfig>> | CacheModuleOptions<StoreConfig>;
43 /**
44 * Dependencies that a Factory may inject.
45 */
46 inject?: any[];
47 extraProviders?: Provider[];
48 /**
49 * If "true', register `CacheModule` as a global module.
50 */
51 isGlobal?: boolean;
52}