pamelafox/lscache — pull request #10 by Jakobo (2011-11-16 21:35:32+00:00)
Title: Implement LRU for cache expiry when quota exceeded

I took an alternate stab at #3, using an LRU to mimic what memcache does per-slab. The result is a pruning of the oldest-touched items first. The cost tradeoffs are worth considering however:

* we add an additional key for tracking last-touched time. This is partially mitigated by shortening the keys used to -EXP and -LRU, with the added bonus of quick scanning in localStorage
* we add an additional write on access and save to record the last-touched value. This shouldn't hit performance hard, but I suppose if you're going crazy the extra call could cause pain when doing thousands of these ops per second.
* we reduce the clobbering algorithm to do the least number of removals, and therefore retain the highest number of cache hits.