import { NotFoundError } from './error' ; export class InMemoryDB { private _data : Record < string , Buffer > = { } ; public async get ( key ) { const keyStr = key . toString ( 'binary' ) ; const val = this . _data [ keyStr ] ; if ( ! val ) { throw new NotFoundError ( `Key ${ key . toString ( 'hex' ) } does not exist` ) ; } return val ; } public async set ( key , value ) { const keyStr = key . toString ( 'binary' ) ; this . _data [ keyStr ] = value ; } public async del ( key ) { const keyStr = key . toString ( 'binary' ) ; delete this . _data [ keyStr ] ; } }