I'm looking for a way to do in the browser what Memcached offers, i.e. ability to configure a size limit (e.g. the localStorage quota) and it will evict old items automatically to keep the cache under limit.
The benefit is no explicit deletions are ever needed, as long as the cache keys are versioned/timestamped. I've seen some libraries that do similar with a "number of items" limit, but size limit would be more useful to stay under the browser's quota.
If you want to use a solution that already exists for this functionality then you can check out this library runtime-memcache implements lru
and a few other caching schemes(mru
, timeout
) in javascript.
It uses modified Doubly Linked List to achieve O(1) for get
, set
and remove
.