import ICacheProvider from '../../models/ICacheProvider' ; interface ICacheData { [ key ] : string ; } export default class FakeCachePRovider implements ICacheProvider { private cache : ICacheData = { } ; public async save ( key , value ) { this . cache [ key ] = JSON . stringify ( value ) ; } public async recover < T > ( key ) { const data = this . cache [ key ] ; if ( ! data ) { return null ; } const parsedData = JSON . parse ( data ) as T ; return parsedData ; } public async invalidate ( key ) { delete this . cache [ key ] ; } public async invalidatePrefix ( prefix ) { const keys = Object . keys ( this . cache ) . filter ( key => key . startsWith ( `${ prefix }:` ) ) ; keys . forEach ( key => { delete this . cache [ key ] ; } ) ; } }