Skip to content
This repository was archived by the owner on May 11, 2025. It is now read-only.

Commit 9721197

Browse files
committed
2.0-beta.3.1
1 parent 1c0cb9c commit 9721197

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

cache.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,22 +46,23 @@ class Cache {
4646
}
4747
if (n > 0) logger.debug(`Clean ${n} Caches`);
4848
}
49-
}, 1800);
49+
}, this.expiration / 2);
5050
}
5151

5252
wrap(func: (...params: any[]) => Promise<any>): (...params: any[]) => Promise<any> {
5353
/**
5454
* Async Function Cache.
5555
*/
5656

57-
const _this = this;
57+
const _this: Cache = this;
58+
const name: string = func.name[0] === "_" ? func.name.slice(1) : func.name;
5859
return async function (...params : any[]) {
59-
const key: string = func.name + JSON.stringify(params);
60+
const key: string = name + JSON.stringify(params);
6061
if (_this.exist(key)) {
61-
logger.debug(`Hit Cache <${func.name}>`)
62+
logger.debug(`Hit Cache <${name}>`)
6263
return _this.get(key);
6364
} else {
64-
logger.info(`Cache Response ${func.name}`); // @ts-ignore
65+
logger.info(`Cache Response <${name}>`); // @ts-ignore
6566
const response: any = await func(...params);
6667
_this.set(key, response);
6768
return response;

0 commit comments

Comments
 (0)