{"name":"record-cache","version":"1.0.2","description":"Cache optimised for record like things","main":"index.js","dependencies":{},"devDependencies":{"standard":"^10.0.3","tape":"^4.8.0"},"scripts":{"test":"standard && tape test.js"},"repository":{"type":"git","url":"git+https://github.com/mafintosh/record-cache.git"},"author":{"name":"Mathias Buus","url":"@mafintosh"},"license":"MIT","bugs":{"url":"https://github.com/mafintosh/record-cache/issues"},"homepage":"https://github.com/mafintosh/record-cache","gitHead":"05d0f6d2fb5a8e24d934b44ab37be34d997377a9","_id":"record-cache@1.0.2","_npmVersion":"5.6.0","_nodeVersion":"9.11.1","_npmUser":{"name":"mafintosh","email":"mathiasbuus@gmail.com"},"dist":{"integrity":"sha512-gI2idHGXCt5eqmOZPD06S711EOLLhSPdJwXREZcjDG7LcbrLa9dMwd6FkEnm2/VsXiMD6y+ZAWOoymrlT87pow==","shasum":"41732bd214d189ea8b25f0f6e5933ecdfdcbe244","tarball":"http://registry-npm.ywwl.com/record-cache/download/record-cache-1.0.2.tgz","fileCount":7,"unpackedSize":11285,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJa3cuyCRA9TVsSAnZWagAAslkQAJiBCUHrB66Aq6CjgtGY\nQfdnfH4aYSU/ygGxsouyQP1b9ol80V1SvwS5q54RcAISqMGmtqBTvS3MuRQz\nEl8qk2fuQjIlMSfz2pGQcUcwneZtfmtxMYFpwHrmuC91TZr2oF6i3bcKLJ2j\n5y/U26GvHx71WJoPzWrOlzg+STuDqUQ0uJrbgBJ7tRmmCzbQzkBsaue6PKdc\n+ZMENzjwhI8eNxk0EJyCLV4f1MZyCWQ003mE2fZ7nuEzSj5fjnmg1l73UhL8\nTMR+AUCZlJGFH6Wq+/tiRz/Sc8BDXUWQKJ8iJo+fm+idhz3NOtH5KKkxbsOD\nJg5s/XZJ5v7LOc3a8tmxCMnfUlZpk8ERXQTCerjF+ON6T6haoFIr/qCSBd6d\nRL7KzPoPDZ2n6GGbmR3SEyJpEc2FqKHQBO8pDhpQ9baH5YQhxlGebHY5pi3R\n11UKJ+dNh9pimsuCmZpB3L9UMXClVjmDCchONLrY5Ae9UOfc+SHGgafYuQtk\nDa3XEYkz1h4D64ly9Vk/iPWVRbIp2FGCm9XSS+5nIG2li9is6PsSNnmylwdb\nsBGgJGTDmqK9j7g2rBQR/qex+waKRX/sKycNYBK2Ggkl97ES0Pr3gnguj8ZB\nNbKoKsJNbk3/bvLjvVjPPo+vCk6x6kYDnSkejVHbtlytcNpHse6oyDIAHzPL\nvzfp\r\n=T2Dt\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIF7bpYBDrAYi8IscLtaHTO0rijxLlx5Dv8R5foQ20LrxAiEA5aD6qOS3eSIlt6WqYNN4cZYV2ZZ9B9SWZ/+ZB0sRawo="}],"size":3774,"noattachment":false,"key":"/record-cache/-/record-cache-1.0.2.tgz"},"maintainers":[{"name":"mafintosh","email":"mathiasbuus@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/record-cache_1.0.2_1524485042061_0.34474977091835024"},"_hasShrinkwrap":false,"readme":"# record-cache\n\nCache optimised for record like things like `host:port` or `domain.names`.\n\n```\nnpm install record-cache\n```\n\n[![build status](https://travis-ci.org/mafintosh/record-cache.svg?branch=master)](https://travis-ci.org/mafintosh/record-cache)\n\n## Usage\n\n``` js\nvar recordCache = require('record-cache')\n\nvar cache = recordCache({\n  maxSize: 1000 // store ~1000 values at max\n  maxAge: 1000 // gc values older than ~1000ms\n})\n\ncache.add('hello', '127.0.0.1')\ncache.add('hello', '127.0.1.1')\ncache.add('hello', '127.0.0.2')\n\nconsole.log(cache.get('hello', 2)) // prints two of the above\n\n// wait 2s\nsetTimeout(function () {\n  console.log(cache.get('hello', 2)) // prints []\n}, 2000)\n```\n\n## API\n\n#### `var cache = recordCache([options])`\n\nCreate a new record cache.\n\nOptions include:\n\n``` js\n{\n  maxSize: 1000, // approximate max size\n  maxAge: 1000, // approximate max age in ms\n  onStale: false // function called when evicting stale records\n}\n```\n\nIn the worst case the cache will be `2 * maxSize` large, and\nif `maxAge` is used old values are gc'ed every `0.66 * maxAge - 1.33 * maxAge` with an optional callback to the `onStale` function upon record eviction.\n\nThis is to greatly simplify the data structures and also gives us a pretty decent\nperf boost compared to other cache modules out there.\n\n#### `cache.add(recordName, value)`\n\nPush a new value to the record set. `value` should be serialisable.\n\n#### `cache.remove(recordName, value)`\n\nRemove a value from the record set. `value` should be a previously added value.\n\n#### `var list = cache.get(recordName, [maxCount])`\n\nGet a list of values from the record set. The list will be randomised.\nSpecify `maxCount` to only get this many values at max.\n\n#### `cache.size`\n\nGet the actual size of the cache.\n\n#### `cache.clear()`\n\nClear all values from the cache.\n\n#### `cache.destroy()`\n\nCompletely destroy the cache. Needed if you are using the `maxAge` option to\ncancel the gc timer.\n\n## License\n\nMIT\n","publish_time":1524485042168,"_cnpm_publish_time":1524485042168,"dist-tags":{"latest":"2.0.0"}}