{ "_args": [ [ { "raw": "lru-cache@^4.0.1", "scope": null, "escapedName": "lru-cache", "name": "lru-cache", "rawSpec": "^4.0.1", "spec": ">=4.0.1 <5.0.0", "type": "range" }, "/Volumes/2009-SSD/GT2/GT2-iOS/node_modules/cross-spawn" ] ], "_from": "lru-cache@>=4.0.1 <5.0.0", "_id": "lru-cache@4.1.1", "_inCache": true, "_location": "/lru-cache", "_nodeVersion": "8.0.0", "_npmOperationalInternal": { "host": "s3://npm-registry-packages", "tmp": "tmp/lru-cache-4.1.1.tgz_1497150046014_0.012352559482678771" }, "_npmUser": { "name": "isaacs", "email": "i@izs.me" }, "_npmVersion": "5.0.3", "_phantomChildren": {}, "_requested": { "raw": "lru-cache@^4.0.1", "scope": null, "escapedName": "lru-cache", "name": "lru-cache", "rawSpec": "^4.0.1", "spec": ">=4.0.1 <5.0.0", "type": "range" }, "_requiredBy": [ "/cross-spawn" ], "_resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.1.tgz", "_shasum": "622e32e82488b49279114a4f9ecf45e7cd6bba55", "_shrinkwrap": null, "_spec": "lru-cache@^4.0.1", "_where": "/Volumes/2009-SSD/GT2/GT2-iOS/node_modules/cross-spawn", "author": { "name": "Isaac Z. Schlueter", "email": "i@izs.me" }, "bugs": { "url": "https://github.com/isaacs/node-lru-cache/issues" }, "dependencies": { "pseudomap": "^1.0.2", "yallist": "^2.1.2" }, "description": "A cache object that deletes the least-recently-used items.", "devDependencies": { "benchmark": "^2.1.4", "standard": "^5.4.1", "tap": "^10.3.3" }, "directories": {}, "dist": { "integrity": "sha512-q4spe4KTfsAS1SUHLO0wz8Qiyf1+vMIAgpRYioFYDMNqKfHQbg+AVDH3i4fvpl71/P1L0dBl+fQi+P37UYf0ew==", "shasum": "622e32e82488b49279114a4f9ecf45e7cd6bba55", "tarball": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.1.tgz" }, "files": [ "index.js" ], "gitHead": "e992f26547a575299fc8d232580e53229393ea7a", "homepage": "https://github.com/isaacs/node-lru-cache#readme", "keywords": [ "mru", "lru", "cache" ], "license": "ISC", "main": "index.js", "maintainers": [ { "name": "isaacs", "email": "isaacs@npmjs.com" }, { "name": "othiym23", "email": "ogd@aoaioxxysz.net" } ], "name": "lru-cache", "optionalDependencies": {}, "readme": "# lru cache\n\nA cache object that deletes the least-recently-used items.\n\n[![Build Status](https://travis-ci.org/isaacs/node-lru-cache.svg?branch=master)](https://travis-ci.org/isaacs/node-lru-cache) [![Coverage Status](https://coveralls.io/repos/isaacs/node-lru-cache/badge.svg?service=github)](https://coveralls.io/github/isaacs/node-lru-cache)\n\n## Installation:\n\n```javascript\nnpm install lru-cache --save\n```\n\n## Usage:\n\n```javascript\nvar LRU = require(\"lru-cache\")\n , options = { max: 500\n , length: function (n, key) { return n * 2 + key.length }\n , dispose: function (key, n) { n.close() }\n , maxAge: 1000 * 60 * 60 }\n , cache = LRU(options)\n , otherCache = LRU(50) // sets just the max size\n\ncache.set(\"key\", \"value\")\ncache.get(\"key\") // \"value\"\n\n// non-string keys ARE fully supported\nvar someObject = {}\ncache.set(someObject, 'a value')\ncache.set('[object Object]', 'a different value')\nassert.equal(cache.get(someObject), 'a value')\n\ncache.reset() // empty the cache\n```\n\nIf you put more stuff in it, then items will fall out.\n\nIf you try to put an oversized thing in it, then it'll fall out right\naway.\n\n## Options\n\n* `max` The maximum size of the cache, checked by applying the length\n function to all values in the cache. Not setting this is kind of\n silly, since that's the whole purpose of this lib, but it defaults\n to `Infinity`.\n* `maxAge` Maximum age in ms. Items are not pro-actively pruned out\n as they age, but if you try to get an item that is too old, it'll\n drop it and return undefined instead of giving it to you.\n* `length` Function that is used to calculate the length of stored\n items. If you're storing strings or buffers, then you probably want\n to do something like `function(n, key){return n.length}`. The default is\n `function(){return 1}`, which is fine if you want to store `max`\n like-sized things. The item is passed as the first argument, and\n the key is passed as the second argumnet.\n* `dispose` Function that is called on items when they are dropped\n from the cache. This can be handy if you want to close file\n descriptors or do other cleanup tasks when items are no longer\n accessible. Called with `key, value`. It's called *before*\n actually removing the item from the internal cache, so if you want\n to immediately put it back in, you'll have to do that in a\n `nextTick` or `setTimeout` callback or it won't do anything.\n* `stale` By default, if you set a `maxAge`, it'll only actually pull\n stale items out of the cache when you `get(key)`. (That is, it's\n not pre-emptively doing a `setTimeout` or anything.) If you set\n `stale:true`, it'll return the stale value before deleting it. If\n you don't set this, then it'll return `undefined` when you try to\n get a stale entry, as if it had already been deleted.\n* `noDisposeOnSet` By default, if you set a `dispose()` method, then\n it'll be called whenever a `set()` operation overwrites an existing\n key. If you set this option, `dispose()` will only be called when a\n key falls out of the cache, not when it is overwritten.\n\n## API\n\n* `set(key, value, maxAge)`\n* `get(key) => value`\n\n Both of these will update the \"recently used\"-ness of the key.\n They do what you think. `maxAge` is optional and overrides the\n cache `maxAge` option if provided.\n\n If the key is not found, `get()` will return `undefined`.\n\n The key and val can be any value.\n\n* `peek(key)`\n\n Returns the key value (or `undefined` if not found) without\n updating the \"recently used\"-ness of the key.\n\n (If you find yourself using this a lot, you *might* be using the\n wrong sort of data structure, but there are some use cases where\n it's handy.)\n\n* `del(key)`\n\n Deletes a key out of the cache.\n\n* `reset()`\n\n Clear the cache entirely, throwing away all values.\n\n* `has(key)`\n\n Check if a key is in the cache, without updating the recent-ness\n or deleting it for being stale.\n\n* `forEach(function(value,key,cache), [thisp])`\n\n Just like `Array.prototype.forEach`. Iterates over all the keys\n in the cache, in order of recent-ness. (Ie, more recently used\n items are iterated over first.)\n\n* `rforEach(function(value,key,cache), [thisp])`\n\n The same as `cache.forEach(...)` but items are iterated over in\n reverse order. (ie, less recently used items are iterated over\n first.)\n\n* `keys()`\n\n Return an array of the keys in the cache.\n\n* `values()`\n\n Return an array of the values in the cache.\n\n* `length`\n\n Return total length of objects in cache taking into account\n `length` options function.\n\n* `itemCount`\n\n Return total quantity of objects currently in cache. Note, that\n `stale` (see options) items are returned as part of this item\n count.\n\n* `dump()`\n\n Return an array of the cache entries ready for serialization and usage\n with 'destinationCache.load(arr)`.\n\n* `load(cacheEntriesArray)`\n\n Loads another cache entries array, obtained with `sourceCache.dump()`,\n into the cache. The destination cache is reset before loading new entries\n\n* `prune()`\n\n Manually iterates over the entire cache proactively pruning old entries\n", "readmeFilename": "README.md", "repository": { "type": "git", "url": "git://github.com/isaacs/node-lru-cache.git" }, "scripts": { "postpublish": "git push origin --all; git push origin --tags", "posttest": "standard test/*.js index.js", "postversion": "npm publish", "preversion": "npm test", "test": "tap test/*.js --100 -J" }, "version": "4.1.1" }