{"name":"record-cache","version":"1.1.1","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":"e109417c413c2044eca6b35d35fc1ea1958ad120","_id":"record-cache@1.1.1","_nodeVersion":"16.1.0","_npmVersion":"6.14.13","dist":{"integrity":"sha512-L5hZlgWc7CmGbztnemQoKE1bLu9rtI2skOB0ttE4C5+TVszLE8Rd0YLTROSgvXKLAqPumS/soyN5tJW5wJLmJQ==","shasum":"ba3088a489f50491a4af7b14d410822c394fb811","tarball":"http://registry-npm.ywwl.com/record-cache/download/record-cache-1.1.1.tgz","fileCount":7,"unpackedSize":11697,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgp6RzCRA9TVsSAnZWagAA/lAP/iO56cYJaZU/HUeeXHvJ\nJHpmlSfuT8mBk+ex8Q/fLjJX7JXfMRpZ9p7/3rmoDv9f1Gpf3AWuF1u//yje\nAO46mJuxBFB3C6kiUWwn7FfHXYc1Lwz5/OX1d735TcT/D7EnXXa1sX3CCqFJ\n318c2bKllT/xTZGNz873pzx85F5T7Q4MTAik2qW9rZiUjC0pZxzb5VwWw27W\n7syChYOSxEHZUPW1kaToQtOdfmlL2U+Sr9j9+6yE2F0HQKanJBWasY15/TCn\ncQU2PFTPr5V/Pcq+y8pGl+HxwC5btj93uwuEqrEBRkAp8Oqf8EZW/BH4jG5d\njJB3M55NqulweIsD4C9BWyIr9ltrCryJQWaWgQb26iu8SX6CGF69q06U2eki\nCDUIRJM5oYS55GqIhvxEfj374qAq2tGj9e9Y3xnRG5d6nxDCU5KCuKCiJWOT\n7hFCUpLRWREUQXfOrRa+OJ4lacbIdySNItwWwGppBcab+A+KO994Py/9TP7+\n5ZZ/ELuxJbMDIkFFMkSjXsog6ebY/hWBiPh85w86bECyFl4/D8u5aY8CNYId\nymxZ2uVJikhpVuCFpm72Nw9UA9yaH/EaVGBjOLY+ZeKCcyDfD7x5WLoRm2Ls\nzAq1hNxo4Y6/DOWHacVTlzJ0JNirCUB89IT+v9Rvkt4RbT2BhkMxJRMVFgOY\nYSja\r\n=6Ryl\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCVaTr1IOu3XNkRCQBzITb0gFgUwQJZP0YoE20hxv0MWQIhAP2O7r1w5CdTWlPj2oTYSsPPjfjsPQmFjTF30qcaPDmM"}],"size":3881,"noattachment":false,"key":"/record-cache/-/record-cache-1.1.1.tgz"},"_npmUser":{"name":"mafintosh","email":"mathiasbuus@gmail.com"},"directories":{},"maintainers":[{"name":"mafintosh","email":"mathiasbuus@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/record-cache_1.1.1_1621599346836_0.373737528642484"},"_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":1621599346987,"_cnpm_publish_time":1621599346987,"dist-tags":{"latest":"2.0.0"}}