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(key: string) { return await this.cacheManager.get(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); } async getTtl(key: string) { return await this.cacheManager.ttl(key); } }