Skip to content

Commit 0a1f44a

Browse files
bugfix(common) export CACHE_MANAGER, fix trackBy method
1 parent d048f23 commit 0a1f44a

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

packages/common/cache/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
export { CACHE_MANAGER } from './cache.constants';
12
export * from './cache.module';
23
export * from './decorators';
34
export * from './interceptors';

packages/common/cache/interceptors/cache.interceptor.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export class CacheInterceptor implements NestInterceptor {
3232
context: ExecutionContext,
3333
call$: Observable<any>,
3434
): Promise<Observable<any>> {
35-
const key = this.getCacheKey(context);
35+
const key = this.trackBy(context);
3636
if (!key) {
3737
return call$;
3838
}
@@ -47,12 +47,16 @@ export class CacheInterceptor implements NestInterceptor {
4747
}
4848
}
4949

50-
getCacheKey(context: ExecutionContext): string | undefined {
50+
trackBy(context: ExecutionContext): string | undefined {
5151
if (!this.isHttpApp) {
5252
return this.reflector.get(CACHE_KEY_METADATA, context.getHandler());
5353
}
5454
const request = context.getArgByIndex(0);
55-
if (this.httpServer.getRequestMethod(request) !== 'GET') {
55+
const excludePaths = [];
56+
if (
57+
this.httpServer.getRequestMethod(request) !== 'GET' ||
58+
excludePaths.includes(this.httpServer.getRequestUrl)
59+
) {
5660
return undefined;
5761
}
5862
return this.httpServer.getRequestUrl(context.getArgByIndex(0));

0 commit comments

Comments
 (0)