localforage-lru-driver
Localforage driver that maintains cache size depending on least-recently-used(lru) principle. localForage.
Requirements
- localforage v1.4.0+
- localforage-removeitems v1.4.0+
- localforage-indexes v1.0.2+
Installation
npm i localforage-lru-driver
Usage
Inserting into your project
;; localforage
When items count exceed cacheSize
, least recently used item is removed:
// .... set items with keys KEY_1 ... KEY_100 lf // 100);
Each time an entry is accessed through getItem
or setItem
it is updated:
// .... set items with keys KEY_1 ... KEY_100. KEY_1 is set first lf // last access time updated // 100 // still present in the localforage
Contructor options
cacheSize
Maximum number of entries allowed to store
Default value: 1000
lruKey
Name of the key that is used for keeping last access timestamp
Default value: ACCESS_TIME
lruIndex
Name of the index that is used for sorting items by last access time
Default value: lruIndex