{"name":"receptacle","version":"1.0.0","description":"In memory cache lru cache with ttl support.","author":{"name":"Dylan Piercey","email":"pierceydylan@gmail.com"},"main":"index.js","license":"MIT","repository":{"type":"git","url":"git+https://github.com/DylanPiercey/receptacle.git"},"keywords":["cache","lru","ttl","expires","map","receptacle","memory"],"devDependencies":{"gulp":"^3.9.0","gulp-mocha":"^2.1.3"},"dependencies":{"ms":"^0.7.1"},"gitHead":"bf487322d551323b5ff7d8282be47998e9660d63","bugs":{"url":"https://github.com/DylanPiercey/receptacle/issues"},"homepage":"https://github.com/DylanPiercey/receptacle#readme","_id":"receptacle@1.0.0","scripts":{},"_shasum":"4164e74ab76689bf18c049e1109d4008ec8ff13c","_from":".","_npmVersion":"3.8.8","_nodeVersion":"5.6.0","_npmUser":{"name":"dylanpiercey","email":"pierceydylan@gmail.com"},"maintainers":[{"name":"dylanpiercey","email":"pierceydylan@gmail.com"},{"name":"rill","email":"rill.github@gmail.com"}],"dist":{"shasum":"4164e74ab76689bf18c049e1109d4008ec8ff13c","tarball":"http://registry-npm.ywwl.com/receptacle/download/receptacle-1.0.0.tgz","integrity":"sha512-sJkZ4sITpBCLe//BeYg/tktk72vG++7wOC2f4Xx9KnnTsn8/kPSxQa1RZtPn90Rd76GoL2n1NG7WAbxsYRQSNA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDAIEreUtHCwvKc2tJGAnDbx2LnJX/oYDe6A7LZMZMJngIgEIjYCMx4LiHm5oEq+32bPo1pfs0xxkhrBtGu4dzyYBs="}],"size":3880,"noattachment":false,"key":"/receptacle/-/receptacle-1.0.0.tgz"},"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/receptacle-1.0.0.tgz_1462916098367_0.31270908983424306"},"directories":{},"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":1462916099712,"_cnpm_publish_time":1462916099712,"dist-tags":{"latest":"1.3.2"}}