feat: add loggers to all services

This commit is contained in:
Abdalhamid Alhamad
2024-12-30 10:35:36 +03:00
parent cb54311a7b
commit 0fd2066c4a
22 changed files with 320 additions and 51 deletions

View File

@ -1,19 +1,23 @@
import { Inject, Injectable } from '@nestjs/common';
import { Inject, Injectable, Logger } from '@nestjs/common';
import { Cacheable } from 'cacheable';
@Injectable()
export class CacheService {
private readonly logger = new Logger(CacheService.name);
constructor(@Inject('CACHE_INSTANCE') private readonly cache: Cacheable) {}
get<T>(key: string): Promise<T | undefined> {
this.logger.log(`Getting value for key ${key}`);
return this.cache.get(key);
}
async set<T>(key: string, value: T, ttl?: number | string): Promise<void> {
this.logger.log(`Setting value for key ${key}`);
await this.cache.set(key, value, ttl);
}
async delete(key: string): Promise<void> {
this.logger.log(`Deleting value for key ${key}`);
await this.cache.delete(key);
}
}