{"_id":"nice-cache","_rev":"17-2af07cf45b459cd8932791e187f07aa7","name":"nice-cache","description":"A node.js in-memory cache - get, set, or subscribe to the auto-updater loop","dist-tags":{"latest":"0.0.5"},"versions":{"0.0.1":{"name":"nice-cache","version":"0.0.1","description":"A node.js in-memory cache - get, set, or subscribe to the auto-updater loop","main":"index.js","scripts":{"test":"mocha"},"repository":{"type":"git","url":"https://github.com/opentable/nice-cache"},"keywords":["event","cache","pub","sub"],"author":{"name":"Matteo Figus"},"license":"MIT","bugs":{"url":"https://github.com/opentable/nice-cache/issues"},"homepage":"https://github.com/opentable/nice-cache","devDependencies":{"mocha":"1.18.2","should":"3.3.1"},"_id":"nice-cache@0.0.1","_shasum":"b291a47d44f43879a346fcea3de8c769e012726b","_from":".","_npmVersion":"1.4.7","_npmUser":{"name":"matteofigus","email":"matteofigus@gmail.com"},"maintainers":[{"name":"matteofigus","email":"matteofigus@gmail.com"}],"dist":{"shasum":"b291a47d44f43879a346fcea3de8c769e012726b","tarball":"https://registry.npmjs.org/nice-cache/-/nice-cache-0.0.1.tgz","integrity":"sha512-pDyF0rh5w0HAYKen0WkXBUARYT87nh9+7NU1OVQhXfKYjNFJvWmkbwDsYeqanfsX9rzpOTm0cjDI9ZoAXPKUAw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHdcTwm9l8V/jw7Mmqudk02carfctxRulFn1s9I8vE9QAiAkOsn2ii/My1xtMaGuUnAxw0rnwpMo9a+FiaGS4A6A5A=="}]},"directories":{}},"0.0.2":{"name":"nice-cache","version":"0.0.2","description":"A node.js in-memory cache - get, set, or subscribe to the auto-updater loop","main":"index.js","scripts":{"test":"mocha"},"repository":{"type":"git","url":"https://github.com/opentable/nice-cache"},"keywords":["event","cache","pub","sub"],"author":{"name":"Matteo Figus"},"license":"MIT","bugs":{"url":"https://github.com/opentable/nice-cache/issues"},"homepage":"https://github.com/opentable/nice-cache","devDependencies":{"mocha":"1.18.2","should":"3.3.1"},"_id":"nice-cache@0.0.2","_shasum":"fa7562959a2f9cc4a17c731bd407b7793ec95d71","_from":".","_npmVersion":"1.4.7","_npmUser":{"name":"matteofigus","email":"matteofigus@gmail.com"},"maintainers":[{"name":"matteofigus","email":"matteofigus@gmail.com"}],"dist":{"shasum":"fa7562959a2f9cc4a17c731bd407b7793ec95d71","tarball":"https://registry.npmjs.org/nice-cache/-/nice-cache-0.0.2.tgz","integrity":"sha512-SNNBAFzhudWYACCFbdI+TwSOzwHkkq2Zt+Q8j0D5yW/GPohQNVaWl/J/EWg0b78sqDLWgoKJjY3ZLUanpm1FbA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCID81KlysS07yn+Ym63AG1J+RJOiXpqlAlRHR3uSXs7HLAiBeB1+t0RSAQN7pvax/yEUpDj7iAaxA3wQlCMvIQDRjRg=="}]},"directories":{}},"0.0.3":{"name":"nice-cache","version":"0.0.3","description":"A node.js in-memory cache - get, set, or subscribe to the auto-updater loop","main":"index.js","scripts":{"test":"mocha"},"repository":{"type":"git","url":"https://github.com/opentable/nice-cache"},"keywords":["event","cache","pub","sub"],"author":{"name":"Matteo Figus"},"license":"MIT","bugs":{"url":"https://github.com/opentable/nice-cache/issues"},"homepage":"https://github.com/opentable/nice-cache","devDependencies":{"mocha":"1.18.2","should":"3.3.1"},"_id":"nice-cache@0.0.3","_shasum":"ca49f91bab23d06b135c47a249e2c04ac1e62076","_from":".","_npmVersion":"1.4.7","_npmUser":{"name":"matteofigus","email":"matteofigus@gmail.com"},"maintainers":[{"name":"matteofigus","email":"matteofigus@gmail.com"}],"dist":{"shasum":"ca49f91bab23d06b135c47a249e2c04ac1e62076","tarball":"https://registry.npmjs.org/nice-cache/-/nice-cache-0.0.3.tgz","integrity":"sha512-KZBr6INpY61RsUXYvg+5mypta4jzvKdUQLa6tdysOBGHqYFecJhJ/49+r1a/0lP0CxKzOvUq2fvaiJU3wFTCEw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBY7PhOyRiYvFdx/mxAJYpFJc6m4oGqSFpDa5rkLV9tOAiA8+FmzHUaH4SHuX1PFti4pTpmEU4KlHbppivgQvdyvmQ=="}]},"directories":{}},"0.0.4":{"name":"nice-cache","version":"0.0.4","description":"A node.js in-memory cache - get, set, or subscribe to the auto-updater loop","main":"index.js","scripts":{"test":"mocha"},"repository":{"type":"git","url":"https://github.com/opentable/nice-cache"},"keywords":["event","cache","pub","sub"],"author":{"name":"Matteo Figus"},"license":"MIT","bugs":{"url":"https://github.com/opentable/nice-cache/issues"},"homepage":"https://github.com/opentable/nice-cache","devDependencies":{"mocha":"1.18.2","should":"3.3.1"},"_id":"nice-cache@0.0.4","_shasum":"e173a9a9d39e56241fe38c3ac1e0f0a72a0d5270","_from":".","_npmVersion":"1.4.7","_npmUser":{"name":"matteofigus","email":"matteofigus@gmail.com"},"maintainers":[{"name":"matteofigus","email":"matteofigus@gmail.com"}],"dist":{"shasum":"e173a9a9d39e56241fe38c3ac1e0f0a72a0d5270","tarball":"https://registry.npmjs.org/nice-cache/-/nice-cache-0.0.4.tgz","integrity":"sha512-Z+FE6FxAktiQva81WiBA+QkgmiL7xM60b7493LQNXsYy0ekkVh77AKwVwoKnGdaHqOn86x79DsIT1KXU/73O4g==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEyPIz2Gore27bx3OhRx2CeODyaLqzgo9T5myZev1FltAiA+dxljpWTdle2OlSt8DDa2BTIXIZmBbQcPtILGAIZNpQ=="}]},"directories":{}},"0.0.5":{"name":"nice-cache","version":"0.0.5","description":"A node.js in-memory cache - get, set, or subscribe to the auto-updater loop","main":"index.js","scripts":{"test":"mocha"},"repository":{"type":"git","url":"https://github.com/opentable/nice-cache"},"keywords":["event","cache","pub","sub"],"author":{"name":"Matteo Figus"},"license":"MIT","bugs":{"url":"https://github.com/opentable/nice-cache/issues"},"homepage":"https://github.com/opentable/nice-cache","devDependencies":{"mocha":"1.18.2","should":"3.3.1"},"gitHead":"8da27e2800f52cee3ef0145b49de619146b65830","_id":"nice-cache@0.0.5","_shasum":"bd2a7e064c93925c45ad01906483cdc328742086","_from":".","_npmVersion":"1.4.28","_npmUser":{"name":"matteofigus","email":"matteofigus@gmail.com"},"maintainers":[{"name":"matteofigus","email":"matteofigus@gmail.com"}],"dist":{"shasum":"bd2a7e064c93925c45ad01906483cdc328742086","tarball":"https://registry.npmjs.org/nice-cache/-/nice-cache-0.0.5.tgz","integrity":"sha512-qZT3REsTF4ryWbIWhyv1pCsFW9porhkbpu/JBQ7iWgKBHOVWWDGlFzmI7PsN+2OPUTqZrpsVh+n8/R8+MDausA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDj9bw8QaXFfPu8ZgE6Ui/ZmPPpZ5Tr/PfZgriFlffrwAIgT7VSjbYyUfU5Wjq/tG5ZOmzyYj/GKnKQ6rLB9c0YR0M="}]},"directories":{}}},"readme":"nice-cache\n=============\n\nA nice in-memory cache for node.js. In addiction of the classic auto-flush mechanism, it comes with an auto-refresh mechanism.\n\nNode version: **0.8.0** required\n\nBuild status: [![Build Status](https://secure.travis-ci.org/opentable/nice-cache.png?branch=master)](http://travis-ci.org/opentable/nice-cache)\n\n[![NPM](https://nodei.co/npm/nice-cache.png?downloads=true)](https://npmjs.org/package/nice-cache)\n\n# Installation\n\n```shell\nnpm install nice-cache\n```\n\n# Usage\n\nA simple usage with a web-server that consumes an API or reads from a DB:\n\n* Try getting a value from the cache\n* When a key is not found:\n   * you set the value\n   * then you subscribe a delegate function to the refresh loop, that will happen every 60 seconds.\n\n```js\nvar Cache = require('nice-cache'),\n    http = require('http');\n\nvar cache = new Cache({ refreshInterval: 60 });\n\nhttp.createServer(function (req, res) {\n\n  var getUsers = function(callback){\n    // do something asynchronous...\n    callback(err, result);\n  };\n\n  var users = cache.get('api-responses', 'users');\n\n  if(!!users)\n    return res.end(users);\n\n  getUsers(function(err, result){\n    cache.set('api-responses', 'users', result);\n    cache.sub('api-responses', 'users', getUsers);\n    res.end(result);\n  });\n\n}).listen(1337, '127.0.0.1');\n```\n\n# API\n\n### new Cache([options])\n\nGets the current instance of the cache (eventually after creating it).\n\nThe optional `options` parameter can consist on one of more of the following properties:\n* `singleton`, bool, default `true`, when false returns a new instance after any initialisation.\n* `refreshInterval`, int, default `0`, sets the refresh interval for the subscribed functions (seconds). When 0 it does nothing.\n* `flushInterval`, int, default `0`, sets the flush interval for all the keys. When 0 it never flushes and so values never expire.\n* `verbose`, bool, default `false`, writes stuff on the console for debugging purposes.\n\n### Cache#set([type, ] key, value)\n\nSets a value. Type is optional.\n\n### Cache#get([type, ] key)\n\nGets a value. Type is optional. Returns `undefined` when a key is not found.\n\n### Cache#flush()\n\nCleans the cache\n\n### Cache#sub([type, ] key, func)\n\nSubscribes the key-value assignment (paired with an optional type) to the refresh loop. The asynchronous function will need to have an (err, res) callback.\n\n### Cache#refresh([type, ] key, func)\n\nWhen key-value assignment [previously subscribed to a refresh handler](#cachesubtype--key-func), performs the refresh action immediately (instead of waiting for the `refreshInterval` to expire). `func` is a callback(err, res) containing the result of the refresh action.\n\n# Tests\n\n```shell\nnpm test\n```\n\n# License\n\nMIT\n\n# Contributors\n\n* [@matteofigus](https://github.com/matteofigus)\n","maintainers":[{"email":"agustin@colchado.com","name":"acolchado"},{"email":"arnold.zokas@coderoom.net","name":"arnoldzokas"},{"email":"matteofigus@gmail.com","name":"matteofigus"}],"time":{"modified":"2022-06-21T09:01:23.928Z","created":"2014-04-29T16:23:21.749Z","0.0.1":"2014-04-29T16:23:21.749Z","0.0.2":"2014-04-29T16:28:20.850Z","0.0.3":"2014-04-29T16:42:54.738Z","0.0.4":"2014-04-29T16:46:38.187Z","0.0.5":"2015-01-19T17:03:02.590Z"},"homepage":"https://github.com/opentable/nice-cache","keywords":["event","cache","pub","sub"],"repository":{"type":"git","url":"https://github.com/opentable/nice-cache"},"author":{"name":"Matteo Figus"},"bugs":{"url":"https://github.com/opentable/nice-cache/issues"},"license":"MIT","readmeFilename":"README.md"}