implementação do logger

This commit is contained in:
unknown
2025-03-28 14:42:53 -03:00
parent 9c77880d89
commit 234704c9ba
23 changed files with 7736 additions and 4005 deletions

View File

@@ -0,0 +1,24 @@
import { Inject, Injectable } from '@nestjs/common';
import { Redis } from 'ioredis';
import { IRedisClient } from './IRedisClient';
@Injectable()
export class RedisClientAdapter implements IRedisClient {
constructor(
@Inject('REDIS_CLIENT')
private readonly redis: Redis
) {}
async get<T>(key: string): Promise<T | null> {
const data = await this.redis.get(key);
return data ? JSON.parse(data) : null;
}
async set<T>(key: string, value: T, ttlSeconds = 300): Promise<void> {
await this.redis.set(key, JSON.stringify(value), 'EX', ttlSeconds);
}
async del(key: string): Promise<void> {
await this.redis.del(key);
}
}