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(key: string): Promise { const data = await this.redis.get(key); return data ? JSON.parse(data) : null; } async set(key: string, value: T, ttlSeconds = 300): Promise { await this.redis.set(key, JSON.stringify(value), 'EX', ttlSeconds); } async del(key: string): Promise { await this.redis.del(key); } }