Module for creating ObjectCaches that can be garbage collected. The ObjectCache will delete the least-recently-used entry to make room for new entries.
npm i @neumatter/object-cache
import ObjectCache from '@neumatter/object-cache'
class CustomObject {
constructor () {}
get () {
const objectCache = ObjectCache.from(this, { maxSize })
let value = objectCache.get('key')
if (value === undefined) {
value = someExpensiveOp()
objectCache.set('key', value)
}
return value
}
}