import Logger from 'js-logger' ; import Keyv from 'keyv' ; import { Provider , ProviderTypes } from '../lib/structures/Provider' ; export class KeyvProvider extends Provider { uri : string | undefined ; client : Keyv ; opts : Keyv . Options < any > ; type : ProviderTypes ; constructor ( uri ? , opts ? ) { super ( ) ; this . uri = uri ; this . opts = opts ; this . type = 'keyv' ; this . client = null ; } async init ( ) { this . client = new Keyv ( this . uri , this . opts ) ; Logger . debug ( 'Keyv initializated!' ) ; this . emit ( 'connected' , this . client ) ; return ; } async insert ( key , value , ttl ? ) { const data = await this . update ( key , value , ttl ) ; return data ; } async get ( key ) { const data = await this . client . get ( key ) ; return data ; } async update ( key , value , ttl ? ) { const data = await this . client . set ( key , value , ttl ) ; return data ; } async delete ( key ) { const data = await this . client . delete ( key ) ; return data ; } clear ( ) { return this . client . clear ( ) ; } }