About
This is a Least-Recently Used cache with event hooks and an optional expiry mode that removes keys if they aren't used within the specified time.
Install
npm install --save lru-events
Use
var makeLRU = var lru = var smallLru = var lruWithOptions = smallLrusmallLrusmallLru // "A"smallLrusmallLru // "A"smallLru // undefinedsmallLru // "C"
API
clear :: () -> () -- does not clear event handlers; event callback takes no args.get :: Key -> Valuelength :: () -> Int -- event callback takes length.on :: String -> (Key -> Value -> ()) -- callbacks generally take Key and Value args.peek :: Key -> Value -- does not change recently used order or expiry timesremove :: Key -> Valueset :: Key -> Value -> Value
Defaults
options = max: 1000 // number of items before the least-recently used gets evicted. expiryIfUnused: Infinity // in milliseconds