medikoo / memoizee

Complete memoize/cache solution for JavaScript
ISC License
1.73k stars 61 forks source link

[Feature] Limit Cache Size #65

Closed tusharmath closed 7 years ago

tusharmath commented 7 years ago

This is a real use case especially while building frontend apps and memoizing the view functions. I would personally want to restrict the cache size to 1 for such cases.

Eg:

const view = (p) => {
  return <div>{p.count}</div>
}

const mView = memoize(view)
mView(1) // MISS
mView(2) // MISS
mView(2) // HIT

Generally the view returns really large objects which can cause a significant performance impact if one starts caching all the values.

tusharmath commented 7 years ago

Sorry found how we can do that :D https://github.com/medikoo/memoizee#limiting-cache-size