Jakobo/inject — Issue #15: lscache: change expiry routine to loop w/ removal of oldest item
Author: Jakobo
Created: 2011-11-15 21:28:59+00:00
State: open

Right now, lscache uses a very sledgehammer approach to removing cache items:

https://github.com/pamelafox/lscache/blob/cc9b787f8a03069d1f52a6b64b225eb6a5bbd45e/lscache.js#L82

The oldest 30 items are chopped off. Since this is supposed to be memcache-like, we should actually expire in smaller chunks until we are satisfying the localStorage limit.

* Can this be done in a while loop w/ small removal chunks?
* Can we pre-calculate the size allowed for localstorage to avoid this scenario completely?

Fixes should be done via a fork of https://github.com/pamelafox/lscache and submitted back via pull request