你可以注入
cache-manager
实例
@Inject(CACHE_MANAGER)
. 上
缓存管理器
实例,然后可以调用方法
del(key, cb)
要清除指定密钥的缓存,请参见
docs
是的。
例子
counter = 0;
constructor(@Inject(CACHE_MANAGER) private cacheManager) {}
@Get()
@UseInterceptors(CacheInterceptor)
incrementCounter() {
this.counter++;
return this.counter;
}
@Get('reset')
resetCache() {
const routeToClear = '/';
this.cacheManager.del(routeToClear, () => console.log('clear done'));
}