Merge pull request #33794 from dantman/cache-manager-exports

[cache-manager] Export interfaces
This commit is contained in:
Sheetal Nandi
2019-03-18 12:55:49 -07:00
committed by GitHub
2 changed files with 6 additions and 13 deletions

View File

@@ -1,6 +1,6 @@
import * as cacheManager from 'cache-manager'
const memoryCache = cacheManager.caching({ store: 'memory', max: 100, ttl: 10/*seconds*/ });
const memoryCache: cacheManager.Cache = cacheManager.caching({ store: 'memory', max: 100, ttl: 10/*seconds*/ });
const ttl = 5;
memoryCache.set('foo', 'bar', { ttl: ttl }, (err) => {

View File

@@ -3,17 +3,17 @@
// Definitions by: Simon Gausmann <https://github.com/GausSim>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
interface CachingConfig {
export interface CachingConfig {
ttl: number;
}
interface StoreConfig extends CachingConfig {
export interface StoreConfig extends CachingConfig {
store: string;
max?: number;
isCacheableValue?: (value: any) => boolean;
}
interface Cache {
export interface Cache {
set<T>(key: string, value: T, options: CachingConfig, callback?: (error: any) => void): void;
set<T>(key: string, value: T, ttl: number, callback?: (error: any) => void): void;
set<T>(key: string, value: T, options: CachingConfig): Promise<any>;
@@ -31,12 +31,5 @@ interface Cache {
del(key: string): Promise<any>;
}
declare namespace cacheManager {
function caching(IConfig: StoreConfig): Cache;
function multiCaching(Caches: Cache[]): Cache;
}
export = cacheManager;
export function caching(IConfig: StoreConfig): Cache;
export function multiCaching(Caches: Cache[]): Cache;