{"_id":"array-lru","_rev":"480006","name":"array-lru","description":"A really fast LRU cache for array items (numeric keys)","dist-tags":{"latest":"1.1.1"},"maintainers":[{"name":"mafintosh","email":""}],"time":{"modified":"2021-08-05T09:32:29.000Z","created":"2017-01-23T15:43:11.341Z","1.1.1":"2017-01-23T20:43:16.694Z","1.1.0":"2017-01-23T17:41:42.046Z","1.0.0":"2017-01-23T15:43:11.341Z"},"users":{},"author":{"name":"Mathias Buus","url":"@mafintosh"},"repository":{"type":"git","url":"https://github.com/mafintosh/array-lru.git"},"versions":{"1.1.1":{"name":"array-lru","version":"1.1.1","description":"A really fast LRU cache for array items (numeric keys)","main":"index.js","dependencies":{},"devDependencies":{"hashlru":"^1.0.6","nanobench":"^1.0.3","standard":"^8.6.0","tape":"^4.6.3"},"scripts":{"test":"standard && tape test.js","bench":"node bench.js"},"repository":{"type":"git","url":"https://github.com/mafintosh/array-lru.git"},"author":{"name":"Mathias Buus","url":"@mafintosh"},"license":"MIT","bugs":{"url":"https://github.com/mafintosh/array-lru/issues"},"homepage":"https://github.com/mafintosh/array-lru","gitHead":"21bcf014117293e8ad10cd9d3d71e7c1b67675ed","_id":"array-lru@1.1.1","_shasum":"0c7e1b4e022ae166ff1e8448c595f3181fcd3337","_from":".","_npmVersion":"2.15.11","_nodeVersion":"4.7.0","_npmUser":{"name":"mafintosh","email":"mathiasbuus@gmail.com"},"dist":{"shasum":"0c7e1b4e022ae166ff1e8448c595f3181fcd3337","size":4551,"noattachment":false,"key":"/array-lru/-/array-lru-1.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/array-lru/download/array-lru-1.1.1.tgz"},"maintainers":[{"name":"mafintosh","email":""}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/array-lru-1.1.1.tgz_1485204196064_0.9761799699626863"},"directories":{},"publish_time":1485204196694,"_cnpm_publish_time":1485204196694,"_hasShrinkwrap":false},"1.1.0":{"name":"array-lru","version":"1.1.0","description":"A really fast LRU cache for array items (numeric keys)","main":"index.js","dependencies":{},"devDependencies":{"hashlru":"^1.0.6","nanobench":"^1.0.3","standard":"^8.6.0","tape":"^4.6.3"},"scripts":{"test":"standard && tape test.js","bench":"node bench.js"},"repository":{"type":"git","url":"https://github.com/mafintosh/array-lru.git"},"author":{"name":"Mathias Buus","url":"@mafintosh"},"license":"MIT","bugs":{"url":"https://github.com/mafintosh/array-lru/issues"},"homepage":"https://github.com/mafintosh/array-lru","gitHead":"45cd6ed85e2fd7e0152058a2ec9b175ca70be714","_id":"array-lru@1.1.0","_shasum":"7a6638f04827461f956a01d12e4922bd1de67c37","_from":".","_npmVersion":"2.15.11","_nodeVersion":"4.7.0","_npmUser":{"name":"mafintosh","email":"mathiasbuus@gmail.com"},"dist":{"shasum":"7a6638f04827461f956a01d12e4922bd1de67c37","size":4554,"noattachment":false,"key":"/array-lru/-/array-lru-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/array-lru/download/array-lru-1.1.0.tgz"},"maintainers":[{"name":"mafintosh","email":""}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/array-lru-1.1.0.tgz_1485193300202_0.31180705642327666"},"directories":{},"publish_time":1485193302046,"_cnpm_publish_time":1485193302046,"_hasShrinkwrap":false},"1.0.0":{"name":"array-lru","version":"1.0.0","description":"A really fast LRU cache for array items (numeric keys)","main":"index.js","dependencies":{},"devDependencies":{"hashlru":"^1.0.6","nanobench":"^1.0.3","standard":"^8.6.0","tape":"^4.6.3"},"scripts":{"test":"standard && tape test.js","bench":"node bench.js"},"repository":{"type":"git","url":"https://github.com/mafintosh/array-lru.git"},"author":{"name":"Mathias Buus","url":"@mafintosh"},"license":"MIT","bugs":{"url":"https://github.com/mafintosh/array-lru/issues"},"homepage":"https://github.com/mafintosh/array-lru","gitHead":"7ab40977478cee34f818671b94c7c2519b6e4779","_id":"array-lru@1.0.0","_shasum":"6847257f2138059d19af3de27ed013e2b72f60bf","_from":".","_npmVersion":"2.15.11","_nodeVersion":"4.7.0","_npmUser":{"name":"mafintosh","email":"mathiasbuus@gmail.com"},"dist":{"shasum":"6847257f2138059d19af3de27ed013e2b72f60bf","size":4297,"noattachment":false,"key":"/array-lru/-/array-lru-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/array-lru/download/array-lru-1.0.0.tgz"},"maintainers":[{"name":"mafintosh","email":""}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/array-lru-1.0.0.tgz_1485186190733_0.3676002153661102"},"directories":{},"publish_time":1485186191341,"_cnpm_publish_time":1485186191341,"_hasShrinkwrap":false}},"readme":"# arraylru\n\nA really fast LRU cache for array items (numeric keys)\n\n```\nnpm install array-lru\n```\n\n[![build status](https://travis-ci.org/mafintosh/array-lru.svg?branch=master)](http://travis-ci.org/mafintosh/array-lru)\n\nCredit to [@dominictarr](https://github.com/dominictarr) for telling me about this neat algorithm for LRUs.\n\n## Usage\n\n``` js\nvar alru = require('array-lru')\nvar lru = alru(512) // create a lru that can contain 512 values\n\nlru.set(42, {hello: 'world'})\nconsole.log(lru.get(42)) // {hello: 'world'}\n```\n\nIt works similar to a normal hash table except when a bucket is full it will\nevict the oldest one from the bucket to make room for the new value.\n\n## API\n\n#### `var lru = alru(size, [options])`\n\nCreate a new LRU instance. Options include:\n\n``` js\n{\n  collisions: 4, // how many hash collisions before evicting (default 4)\n  evict: fn, // call this function with (index, value) when someone is evicted\n  indexedValues: false // set to true if your values has a .index property\n}\n```\n\nSize should be a multiple of `collections`. If not, it will be coerced into one.\n\n### `var value = lru.get(index)`\n\nGet a value from the cache. If the index is not found, `null` is returned.\n\n### `lru.set(index, value)`\n\nInsert a new value in the cache. If there is no room in the hash bucket that\n`index` maps to, the oldest value in the bucket will be evicted.\n\n### Performance\n\nOn my MacBook 12\" I can set/get around 7.500.000 values per second, YMMV.\nRun the benchmark using `npm run bench` to test it for yourself.\n\n## License\n\nMIT\n","_attachments":{},"homepage":"https://github.com/mafintosh/array-lru","bugs":{"url":"https://github.com/mafintosh/array-lru/issues"},"license":"MIT"}