rsms / js-lru

A fast, simple & universal Least Recently Used (LRU) map for JavaScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

how to make it work with arbitrary data store

niloy opened this issue · comments

Right now, the cache is in-memory. I am interested in using it in the browser with IndexedDB.

Since this little library is merely just a doubly-linked list with some logic for eviction, there's really nothing you can use IMHO. You might want to implement LRU logic on top of indexeddb (or localstorage.)

Instead of directly using this._keymap, if you use functions like putInStore and getFromStore, I can extend your class and override those methods to use indexedDB.

_keymap is just an optimization for key lookup. The actual data and keys are maintained in a doubly-linked list.