/ stream.nieuweinstituut.nl / node_modules / lru-cache /

[ICO]NameLast modifiedSizeDescription
[PARENTDIR]Parent Directory  -  
[   ]LICENSE40 years ago765  
[TXT]README.md40 years ago5.8Kd768d73 docs [كارل مبارك]
[   ]index.js40 years ago8.0K3e510ca test new git [كارل مبارك]
[   ]package.json2 years ago1.8K3e510ca test new git [كارل مبارك]
README.md

lru cache

A cache object that deletes the least-recently-used items.

Build Status Coverage Status

Installation:

npm install lru-cache --save

Usage:

var LRU = require("lru-cache")
  , options = { max: 500
              , length: function (n, key) { return n * 2 + key.length }
              , dispose: function (key, n) { n.close() }
              , maxAge: 1000 * 60 * 60 }
  , cache = new LRU(options)
  , otherCache = new LRU(50) // sets just the max size

cache.set("key", "value")
cache.get("key") // "value"

// non-string keys ARE fully supported
// but note that it must be THE SAME object, not
// just a JSON-equivalent object.
var someObject = { a: 1 }
cache.set(someObject, 'a value')
// Object keys are not toString()-ed
cache.set('[object Object]', 'a different value')
assert.equal(cache.get(someObject), 'a value')
// A similar object with same keys/values won't work,
// because it's a different object identity
assert.equal(cache.get({ a: 1 }), undefined)

cache.reset()    // empty the cache

If you put more stuff in it, then items will fall out.

If you try to put an oversized thing in it, then it'll fall out right away.

Options

API

Apache/2.4.38 (Debian) Server at www.karls.computer Port 80