mirror of
https://github.com/dadosfera/maestro.git
synced 2026-10-01 03:29:09 +00:00
24 lines
522 B
TypeScript
24 lines
522 B
TypeScript
import { CACHE_MANAGER, Inject, Injectable } from '@nestjs/common';
|
|
import { Cache } from 'cache-manager';
|
|
|
|
@Injectable()
|
|
export class CacheService<T> {
|
|
|
|
constructor(
|
|
@Inject(CACHE_MANAGER)
|
|
private readonly cacheManager: Cache,
|
|
) {}
|
|
|
|
async get(key: string): Promise<T | null> {
|
|
return await this.cacheManager.get<T>(key);
|
|
}
|
|
|
|
async set(key: string, value: T): Promise<void> {
|
|
await this.cacheManager.set(key, value);
|
|
}
|
|
|
|
async delete(key: string) {
|
|
await this.cacheManager.del(key);
|
|
}
|
|
}
|