import ICacheProvider from '../models/ICacheProvider' ; import Redis , { Redis as RedisClient } from 'ioredis' ; import cacheConfig from '@config/cache' ; export default class RedisCacheProvider implements ICacheProvider { private client : RedisClient ; constructor ( ) { this . client = new Redis ( cacheConfig . config . redis ) ; } public async save ( key , value ) { await this . client . set ( key , JSON . stringify ( value ) ) ; } public async recover < T > ( key ) { const data = await this . client . get ( key ) ; if ( ! data ) return null ; const parsedData = JSON . parse ( data ) as T ; return parsedData ; } public async invalidate ( key ) { } }