mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-07 18:50:14 +00:00
Merge pull request #33794 from dantman/cache-manager-exports
[cache-manager] Export interfaces
This commit is contained in:
@@ -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) => {
|
||||
|
||||
17
types/cache-manager/index.d.ts
vendored
17
types/cache-manager/index.d.ts
vendored
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user