import StoreLogger from './StoreLogger' ; export default class StoreCache { cache : any ; logger : StoreLogger ; constructor ( _logger ) { this . cache = { } ; this . logger = _logger ; } public addOrUpdate ( id , message ) { this . cache [ id ] = message ; } public getOrAdd ( id , message ? ) { this . logger . readingCache ( id ) ; if ( ! this . exists ( id ) ) { if ( message === undefined ) { throw new Error ( "Message expected when file does not exist" ) ; } this . logger . missingFromCache ( id ) ; this . addOrUpdate ( id , message ) ; } return this . cache [ id ] ; } public exists ? ( id ) { return this . cache . hasOwnProperty ( id ) ; } public checkCache ( ) { return this . cache ; } }