{"name":"receptacle","description":"In memory cache lru cache with ttl support.","version":"1.3.2","author":{"name":"Dylan Piercey","email":"pierceydylan@gmail.com"},"bugs":{"url":"https://github.com/DylanPiercey/receptacle/issues"},"dependencies":{"ms":"^2.1.1"},"devDependencies":{"browserify":"^16.2.2","bundle-collapser":"^1.3.0","coveralls":"^3.0.1","exorcist":"^1.0.1","istanbul":"^0.4.5","mocha":"^5.2.0","snazzy":"^7.1.1","standard":"^11.0.1","uglifyjs":"^2.4.11"},"files":["index.js","index.d.ts"],"homepage":"https://github.com/DylanPiercey/receptacle","keywords":["cache","expires","lru","map","memory","receptacle","ttl"],"license":"MIT","main":"index.js","repository":{"type":"git","url":"git+https://github.com/DylanPiercey/receptacle.git"},"scripts":{"build":"make build","coveralls":"make coveralls","lint":"make lint","test":"npm run lint && make test","test-ci":"npm run lint && make test-ci"},"typings":"./index.d.ts","standard":{"globals":["GIT_COMMIT","describe","it","before","beforeEach","after","afterEach"],"ignore":["dist/"]},"gitHead":"9a40d7cd046e4eaec145a6677863a42721951802","_id":"receptacle@1.3.2","_npmVersion":"6.1.0","_nodeVersion":"10.3.0","_npmUser":{"name":"dylanpiercey","email":"pierceydylan@gmail.com"},"dist":{"integrity":"sha512-HrsFvqZZheusncQRiEE7GatOAETrARKV/lnfYicIm8lbvp/JQOdADOfhjBd2DajvoszEyxSM6RlAAIZgEoeu/A==","shasum":"a7994c7efafc7a01d0e2041839dab6c4951360d2","tarball":"http://registry-npm.ywwl.com/receptacle/download/receptacle-1.3.2.tgz","fileCount":4,"unpackedSize":12241,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbITzFCRA9TVsSAnZWagAABN4P/36kb9eFdAQHHtiK76ZD\nofqOFG4NWUNsC9C2hgCcUOHhYfO7BQMgW7HXJ5AYbnVZaZxpaiUv8TzZwdI+\nG4esefm9vj650gkMn2n3R7Cwv8wNzmEukYdHfJt2s9Eq7PY25Bz9v30jcXQU\nnLwkGEFhYeOawp/14iOP+PPUtSJeQLCwCp+YM1mOG0NWMJGQByGt0B3Tx2sK\nL/Yl50qwl+TQN3i4dDYsUHTno5LqbEGcMxboJo+JvSXLaCvVqrLZIS81VvU0\nzLGmSEwUelkfcmLJJg+Y6fqRu21Z5X+3RibOB7n7X3XH0xYSd0Vczo1XIpXI\njurwcC5vL0DQwy7cJwLcLOaM35CYCq3Fef9QDG1HtNTELZ71nB3baUbsQf7H\n9hs5CxETtnhrtT/iqCjH1DhMzzecT4D2876F7JKV6zwDSzJBY2AWHXtHMrgJ\nGtAf+/lyAFKy+ZJ1dDRUFMBfVEcSRE6m0pV/lgVXNYtNEIEBEse9CT3MaKYa\nO+uxNkQyuZv99o2aZu5YFtuocI0M6FO5gKQhtak9nTN2JbONiGasijMH+a3R\nK++0U3r7Q0DDlJTp8JeUOcmpPEtr+W9qx/BatpZyMnt6oRxefZri0gsgAIg6\na0PCbbS+kka/0VSvnkNuSViHW8taTXQPNlOK8LiGDUWqH2Sgha9RdPIdIyWj\nQNpp\r\n=WAzY\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDYsHb023kS+A9nEfQj1Rfv6H3pJ2f0Ijf0+GVB/Cs0qQIgctV0BYE722xf4jWQ4mHu7Ny5vNJxaYtp/H1KkqpSri4="}],"size":4157,"noattachment":false,"key":"/receptacle/-/receptacle-1.3.2.tgz"},"maintainers":[{"email":"pierceydylan@gmail.com","name":"dylanpiercey"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/receptacle_1.3.2_1528904901119_0.40379886113425667"},"_hasShrinkwrap":false,"readme":"<h1 align=\"center\">\n  <!-- Logo -->\n  Receptacle\n\n  <br/>\n\n  <!-- Stability -->\n  <a href=\"https://nodejs.org/api/documentation.html#documentation_stability_index\">\n    <img src=\"https://img.shields.io/badge/stability-stable-brightgreen.svg?style=flat-square\" alt=\"API stability\"/>\n  </a>\n  <!-- Standard -->\n  <a href=\"https://github.com/feross/standard\">\n    <img src=\"https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square\" alt=\"Standard\"/>\n  </a>\n  <!-- NPM version -->\n  <a href=\"https://npmjs.org/package/receptacle\">\n    <img src=\"https://img.shields.io/npm/v/receptacle.svg?style=flat-square\" alt=\"NPM version\"/>\n  </a>\n  <!-- Travis build -->\n  <a href=\"https://travis-ci.org/DylanPiercey/receptacle\">\n  <img src=\"https://img.shields.io/travis/DylanPiercey/receptacle.svg?style=flat-square\" alt=\"Build status\"/>\n  </a>\n  <!-- Coveralls coverage -->\n  <a href=\"https://coveralls.io/github/DylanPiercey/receptacle\">\n    <img src=\"https://img.shields.io/coveralls/DylanPiercey/receptacle.svg?style=flat-square\" alt=\"Test Coverage\"/>\n  </a>\n  <!-- File size -->\n  <a href=\"https://github.com/DylanPiercey/receptacle/blob/master/dist/receptacle.js\">\n    <img src=\"https://badge-size.herokuapp.com/DylanPiercey/receptacle/master/dist/receptacle.js?style=flat-square\" alt=\"File size\"/>\n  </a>\n  <!-- Downloads -->\n  <a href=\"https://npmjs.org/package/receptacle\">\n    <img src=\"https://img.shields.io/npm/dm/receptacle.svg?style=flat-square\" alt=\"Downloads\"/>\n  </a>\n  <!-- Gitter chat -->\n  <a href=\"https://gitter.im/DylanPiercey/receptacle\">\n    <img src=\"https://img.shields.io/gitter/room/DylanPiercey/receptacle.svg?style=flat-square\" alt=\"Gitter Chat\"/>\n  </a>\n</h1>\n\nIn memory cache for node and the browser that supports `lru` and `ttl` algorithms.\n\nItems in the cache will move to the back queue when accessed and any key can optionally have an expiry time.\n\n## Installation\n\n\n#### Npm\n```console\nnpm install receptacle\n```\n\n#### [Download](https://raw.githubusercontent.com/DylanPiercey/receptacle/master/dist/receptacle.js)\n```html\n<script type=\"text/javascript\" src=\"receptacle.js\"></script>\n<script>\n    define(['receptacle'], function (receptacle) {...}) // AMD\n    window.receptacle // Global receptacle if no module system in place.\n</script>\n```\n\n## Example\n\n```js\nvar Receptacle = require('receptacle');\nvar cache      = new Receptacle({ max: 100 }); // Create a cache with max 100 items.\n\ncache.set(\"item\", 1, { ttl: 100 }); //-> Add item to cache (expire in 100ms).\ncache.get(\"item\"); //-> 1\ncache.has(\"item\"); //-> true\ncache.expire(\"item\", 50); //-> Expire in 50ms (instead of 100).\ncache.delete(\"item\"); //-> Delete item right away.\ncache.clear(); //-> Empty the cache.\n\n// You can also use the \"refresh\" option to automatically reset a keys expiration when accessed.\ncache.set(\"item\", 1, { ttl: 100, refresh: true });\n// 50ms later\ncache.get(\"item\"); // Resets timer back to 100ms.\n\n// And store meta data about values.\ncache.set(\"item\", 1, { meta: { custom: 1 } });\n// Then retrieve it.\ncache.meta(\"item\"); //-> { custom: 1 }\n```\n\n## Serialization\nYou can easily serialize and rehydrate your cache as JSON.\n\n```js\nvar Receptacle = require('receptacle');\nvar cache      = new Receptacle({ max: 5 }); // Create a cache with max 5 items.\n\ncache.set(\"a\", 1, { ttl: 1000 });\n\nvar serialized = JSON.stringify(cache); //-> '{ \"max\": 5, \"items\": [...] }'\n\n// Create a cache from the json which will retain all ttl information (and remove any keys that have expired).\nvar newCacheFromJSON = new Receptacle(JSON.parse(serialized));\n\n```\n\n## API\n\n###`Receptacle({ max=Infinity, items=[], id=# })`\nCreate a new cache.\n\n###`#id`\nEach cache is assigned a unique id for organizing, you can optionally provide an id during instanciation.\n\n###`#max`\nGet the maximum size of the cache (default of Infinity).\n\n###`#size`\nGet the current number of items in the cache.\n\n###`#has(key)`\nCheck if a key is in the cache, even if it's undefined.\n\n###`#get(key)`\nRetreive a key from the cache.\n\n###`#meta(key)`\nIf a meta option was used with setting an item in the cache it will be returned.\n\n###`#set(key, value, options)`\nSet a key in the cache, optionally setting a `ttl` option that will cause the value to expire.\nIf a `refresh` option is `true` the ttl will automatically reset when the `key` is accessed.\n\n###`#delete(key)`\nImmediately remove a key from the cache.\n\n###`#expire(key, [ms=0])`\nUpdate the expire time for a key. You can also use any valid [ms](https://github.com/rauchg/ms.js) string for a timeout.\n\n###`#clear()`\nRemove all keys from the cache.\n\n---\n\n### Contributions\n\n* Use `npm test` to run tests.\n\nPlease feel free to create a PR!\n","publish_time":1528904901194,"_cnpm_publish_time":1528904901194,"dist-tags":{"latest":"1.3.2"}}