const storage = { } ; export class cache { public static set ( key , value , ttl ) { const expires = new Date ( ) ; expires . setMilliseconds ( expires . getMilliseconds ( ) + ttl ) ; storage [ key ] = { value , expires } ; } public static get ( key ) { const s = storage [ key ] ; if ( ! s ) { return null ; } if ( s . expires < new Date ( ) ) { delete storage [ key ] ; return null ; } return s . value ; } }