chore: complete utils modules
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import { CACHE_MANAGER, Cache } from "@nestjs/cache-manager";
|
||||
import { Inject, Injectable } from "@nestjs/common";
|
||||
|
||||
@Injectable()
|
||||
export class CacheService {
|
||||
constructor(@Inject(CACHE_MANAGER) private cacheManager: Cache) {}
|
||||
|
||||
async get<T>(key: string) {
|
||||
return await this.cacheManager.get<T>(key);
|
||||
}
|
||||
|
||||
async set(key: string, value: string, ttl: number = 120 * 1000) {
|
||||
await this.cacheManager.set(key, value, ttl);
|
||||
}
|
||||
|
||||
async del(key: string) {
|
||||
await this.cacheManager.del(key);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user