import Logger from 'js-logger' ; import LruCache from 'lru-cache' ; import { Provider , ProviderTypes } from '../lib/structures/Provider' ; export class LruCacheProvider extends Provider { client : LruCache < unknown , unknown > ; type : ProviderTypes ; constructor ( options ) { super ( ) ; this . type = 'lrucache' ; this . client = new LruCache ( options ) ; } async init ( ) { Logger . debug ( 'LruCache initializated!' ) ; this . emit ( 'connected' , this . client ) ; return ; } async insert ( key , value , maxAge ? ) { const data = await this . update ( key , value , maxAge ) ; return data ; } async get ( key ) { const data = await this . client . get ( key ) ; return data ; } async update ( key , value , maxAge ? ) { const data = await this . client . set ( key , value , maxAge ) ; return data ; } async delete ( key ) { const data = await this . client . del ( key ) ; return data ; } clear ( ) { return this . client . reset ( ) ; } }