diff --git a/index.d.ts b/index.d.ts index cb46bca..bca0a94 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,3 +1,21 @@ +type ThinkCacheType = 'file' | 'redis'; + +interface ThinkCacheOptionRedis { + /** + * 缓存过期时间(毫秒) + */ + timeout?: number; +} + +interface ThinkCacheOption { + type?: ThinkCacheType; + /** + * 缓存过期时间(毫秒) + */ + timeout?: number; + redis?: ThinkCacheOptionRedis; +} + interface ThinkCacheCtx { /** * get cache @@ -13,14 +31,14 @@ interface ThinkCacheCtx { * else mean set cache * @memberOf CacheExtend */ - cache(name: string, value?: any, config?: object): Promise; + cache(name: string, value?: any, config?: ThinkCacheType | ThinkCacheOption): Promise; /** * get cache * * @memberOf CacheExtend */ - cache(name: string, value: Function): Promise; + cache(name: string, value: Promise): Promise; } declare module 'thinkjs' {