{"_id":"js-cache","_rev":"11-88e387b206d1e0fe858b8f133697ec9a","name":"js-cache","description":"Caching library supporting timeouts, events and external data sources","dist-tags":{"latest":"1.0.3"},"versions":{"0.1.0":{"name":"js-cache","version":"0.1.0","license":"MIT","description":"Caching library supporting timeouts, events and external datasources","keywords":["cache","memory","event"],"author":{"name":"Dirk Bonhomme","email":"dirk@bytelogic.be"},"main":"index","repository":{"type":"git","url":"git://github.com/dirkbonhomme/js-cache"},"scripts":{"test":"./node_modules/.bin/mocha --reporter spec"},"dependencies":{"infinite-timeout":"*","backbone-events-standalone":"*"},"devDependencies":{"mocha":"*","expect.js":"*","sinon":"*"},"engines":{"node":">=0.8"},"readme":"# Caching library for JavaScript and Node.js\n\nSoon..\n\n## Usage in Node.js  \n\nSoon..\n\n## Usage in browsers\n\n**Load script**  \n\n```\n<script src=\"lib/cache.js\"></script> \n```\n...\n\n## Developing\n\nThe library is published to NPM and can be installed with the following command:\n\n    $ npm install js-cache\n\n## Testing\n\nNavigate to this module's repository and make sure you have the development modules installed:\n\n    $ npm install\n\n\nRun the tests:\n\n    $ npm test\n\n","_id":"js-cache@0.1.0","dist":{"shasum":"efd0fbf499433052f9570b636f24d1eda9ba4be6","tarball":"https://registry.npmjs.org/js-cache/-/js-cache-0.1.0.tgz","integrity":"sha512-t1dABwBOPwcF9hnFECvuCcxngSORHZrs4KDQj3QbNvR9zzavaTkckMpAPTufDNGL62+iTD0P4DCiKh9r54szhQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDvtEYEehb7xDKxS2B5V8iSCpPGWPz/hhCquKUVvQufAgIhAPIiP4v8WTJdDpRtdMJr8qT63k/w3JrCdtdh0u/aLeie"}]},"_npmVersion":"1.1.63","_npmUser":{"name":"dirkbonhomme","email":"dirk@bytelogic.be"},"maintainers":[{"name":"dirkbonhomme","email":"dirk@bytelogic.be"}],"directories":{}},"1.0.0":{"name":"js-cache","version":"1.0.0","license":"MIT","description":"Caching library supporting timeouts, events and external data sources","keywords":["cache","memory","event"],"author":{"name":"Dirk Bonhomme","email":"dirk@bytelogic.be"},"main":"index","repository":{"type":"git","url":"git://github.com/dirkbonhomme/js-cache"},"scripts":{"test":"./node_modules/.bin/mocha --reporter spec"},"dependencies":{"infinite-timeout":"*","backbone-events-standalone":"*"},"devDependencies":{"mocha":"*","expect.js":"*","sinon":"*"},"engines":{"node":">=0.8"},"readme":"# Caching library for JavaScript and Node.js\n\nCaching library with support for timeouts, events and external data sources.\n\n## Overview\n\n* [Usage in Node.js](#usage-in-nodejs)\n* [Usage in browsers](#usage-in-browsers)\n* [Instance](#instance)\n* [API](#api)\n* [External data source](#external-data-source)\n* [Events](#events)\n* [Developing](#developing)\n* [Building](#building)\n* [Testing](#testing)\n\n## Usage in Node.js  \n\n    var cache = require('js-cache');\n    cache.set('lorem', 'ipsum', 60000);\n    console.log(cache.get('lorem'));\n    \n    var myCache = new cache();\n    myCache.set('lorem', 'dolor', 60000);\n    console.log(myCache.get('lorem'));\n\n\n## Usage in browsers\n\n    <script src=\"bundle/cache.js\"></script> \n    <script>\n        cache.set('lorem', 'ipsum', 60000);\n        console.log(cache.get('lorem'));\n    </script>\n\n## Instance\n\nIt is possible to call the `cache` object directly:\n\n    cache.set('lorem', 'ipsum');\n    console.log(cache.get('lorem'));\n\nor use it as a constructor to create a separate storage:\n\n    var c2 = new cache();\n    c2.set('lorem', 'dolor');\n    console.log(c2.get('lorem'));\n\n## API\n\n### cache.set(`key`, `value`, `[ttl]`)\n\nCache data or update and existing record.\n\n`key` Unique key identifying the cache  \n`value` Cached value  \n`ttl` Time to live in milliseconds (optional) \n\n### cache.get(`key`, `[callback]`)\n\nGet cached value. Returns cached value (or undefined) if no callback was provided. Always returns undefined if callback argument is present.\n\n`key` Key identifying the cache  \n`callback` Return value in callback if record exists in memory or on external resource (optional)\n\n### cache.del(`key`)\n\nDelete cached data. Returns true if the record existed, false if not.\n\n`key` Key identifying the cache\n\n### cache.clear()\n\nClear all cached data. Returns number of cleared records.\n\n### cache.size()\n                \nReturns number of cached records.\n\n### cache.debug()\n\nReturns internal object with cached records.\n\n## External data source\n\nIt is possible to forward api requests to external handlers. They can be used for logging, storing in persistent database etc. The cache library will function as a temporary, in-memory layer.\n\n    var c = new cache({\n        set: setHandler,\n        get: getHandler,\n        del: delHandler,\n        clear: clearHandler\n    });\n    \nAll handlers are optional.\n    \n`setHandler` is called with `key`, `value`, `ttl` on cache.set().  \n\n`getHandler` is called with `key`, `callback` on cache.get() when a callback is provided and the key is not present in the cache. The getHandler is required to execute `callback`.  \n\n`delHandler` is called with `key` on cache.del(). It is not called when a cached record times out.  \n\n`clearHandler` is called without arguments on cache.clear().  \n\n## Events\n\nThe cache library uses the Backbone event framework. Please refer to their [documentation](http://backbonejs.org/#Events) for a detailed overview. \n\n### set , set:key\n\nEmitted when setting a value to a new record.\n\n    cache.on('set', function(key, value, ttl){});\n    cache.on('set:lorem', function(value, ttl){});\n    cache.set('lorem', 'ipsum', 123);\n    \n### update, update:key\n\nEmitted when updating the value or ttl of a known record.\n\n    cache.set('lorem', 'ipsum');\n    cache.on('update', function(key, value, ttl){});\n    cache.on('update:lorem', function(value, ttl){});\n    cache.set('lorem', 'ipsum', 123);\n\n### del, del:key\n\nEmitted when deleting a record or when a cached record times out.\n\n    cache.set('lorem', 'ipsum');\n    cache.on('del', function(key){});\n    cache.on('del:lorem', function(){});\n    cache.del('lorem');\n    \n### clear\n\nEmitted when the cache gets cleared.\n\n    cache.on('clear', function(size){});\n    cache.clear();\n\n## Developing\n\nThe library is published to NPM and can be installed with the following command:\n\n    $ npm install js-cache\n    \n## Building\n\nThe scripts have to be bundled in order to use them in a browser. One of the tools you can use is browserify.\n\n    $ sudo npm install browserify -g\n    $ make browserify\n    \nThis will build the script in `bundle/cache.js`\n\n## Testing\n\nNavigate to this module's repository and make sure you have the development modules installed:\n\n    $ npm install\n\n\nRun the tests:\n\n    $ npm test\n\n","_id":"js-cache@1.0.0","dist":{"shasum":"96f1aac844038528f12adf04742bd72abe1b0296","tarball":"https://registry.npmjs.org/js-cache/-/js-cache-1.0.0.tgz","integrity":"sha512-8MRf9LEaUyRbNNVSOWUwABa7Dm7wRq1vUhXJa0BH2v8B3XEpfLuaHFH3UbJO+iuO8P5Er4nAeewvZpndYjcZTg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHsupYsfzHrSLb19wsWHzlWbXH2N0RH+6q8+UZMlvHWTAiAheutrpL8AbPhdXNJYIaUo/X44sd4qEaY1nCt+vYlKDA=="}]},"_npmVersion":"1.1.63","_npmUser":{"name":"dirkbonhomme","email":"dirk@bytelogic.be"},"maintainers":[{"name":"dirkbonhomme","email":"dirk@bytelogic.be"}],"directories":{}},"1.0.2":{"name":"js-cache","version":"1.0.2","license":"MIT","description":"Caching library supporting timeouts, events and external data sources","keywords":["cache","memory","event"],"author":{"name":"Dirk Bonhomme","email":"dirk@bytelogic.be"},"main":"index","repository":{"type":"git","url":"git://github.com/dirkbonhomme/js-cache"},"scripts":{"test":"make test"},"config":{"blanket":{"pattern":"lib/cache.js"}},"dependencies":{"infinite-timeout":"*","backbone-events-standalone":"*"},"devDependencies":{"mocha":"*","expect.js":"*","sinon":"*","blanket":"git://github.com/alex-seville/blanket.git#development"},"engines":{"node":">=0.8"},"readme":"# Caching library for JavaScript and Node.js\n\nCaching library with support for timeouts, events and external data sources.\n\n## Overview\n\n* [Usage in Node.js](#usage-in-nodejs)\n* [Usage in browsers](#usage-in-browsers)\n* [Instance](#instance)\n* [API](#api)\n* [External data source](#external-data-source)\n* [Events](#events)\n* [Developing](#developing)\n* [Building](#building)\n* [Testing](#testing)\n\n## Usage in Node.js  \n\n    var cache = require('js-cache');\n    cache.set('lorem', 'ipsum', 60000);\n    console.log(cache.get('lorem'));\n    \n    var myCache = new cache();\n    myCache.set('lorem', 'dolor', 60000);\n    console.log(myCache.get('lorem'));\n\n\n## Usage in browsers\n\n    <script src=\"bundle/cache.js\"></script> \n    <script>\n        cache.set('lorem', 'ipsum', 60000);\n        console.log(cache.get('lorem'));\n    </script>\n\n## Instance\n\nIt is possible to call the `cache` object directly:\n\n    cache.set('lorem', 'ipsum');\n    console.log(cache.get('lorem'));\n\nor use it as a constructor to create a separate storage:\n\n    var c2 = new cache();\n    c2.set('lorem', 'dolor');\n    console.log(c2.get('lorem'));\n\n## API\n\n### cache.set(`key`, `value`, `[ttl]`)\n\nCache data or update and existing record.\n\n`key` Unique key identifying the cache  \n`value` Cached value  \n`ttl` Time to live in milliseconds (optional) \n\n### cache.get(`key`, `[callback]`)\n\nGet cached value. Returns cached value (or undefined) if no callback was provided. Always returns undefined if callback argument is present.\n\n`key` Key identifying the cache  \n`callback` Return value in callback if record exists in memory or on external resource (optional)\n\n### cache.del(`key`)\n\nDelete cached data. Returns true if the record existed, false if not.\n\n`key` Key identifying the cache\n\n### cache.clear()\n\nClear all cached data. Returns number of cleared records.\n\n### cache.size()\n                \nReturns number of cached records.\n\n### cache.debug()\n\nReturns internal object with cached records.\n\n## External data source\n\nIt is possible to forward api requests to external handlers. They can be used for logging, storing in persistent database etc. The cache library will function as a temporary, in-memory layer.\n\n    var c = new cache({\n        set: setHandler,\n        get: getHandler,\n        del: delHandler,\n        clear: clearHandler\n    });\n    \nAll handlers are optional.\n    \n`setHandler` is called with `key`, `value`, `ttl` on cache.set().  \n\n`getHandler` is called with `key`, `callback` on cache.get() when a callback is provided and the key is not present in the cache. The getHandler is required to execute `callback`.  \n\n`delHandler` is called with `key` on cache.del(). It is not called when a cached record times out.  \n\n`clearHandler` is called without arguments on cache.clear().  \n\n## Events\n\nThe cache library uses the Backbone event framework. Please refer to their [documentation](http://backbonejs.org/#Events) for a detailed overview. \n\n### set , set:key\n\nEmitted when setting a value to a new record.\n\n    cache.on('set', function(key, value, ttl){});\n    cache.on('set:lorem', function(value, ttl){});\n    cache.set('lorem', 'ipsum', 123);\n    \n### update, update:key\n\nEmitted when updating the value or ttl of a known record.\n\n    cache.set('lorem', 'ipsum');\n    cache.on('update', function(key, value, ttl){});\n    cache.on('update:lorem', function(value, ttl){});\n    cache.set('lorem', 'ipsum', 123);\n\n### del, del:key\n\nEmitted when deleting a record or when a cached record times out.\n\n    cache.set('lorem', 'ipsum');\n    cache.on('del', function(key){});\n    cache.on('del:lorem', function(){});\n    cache.del('lorem');\n    \n### clear\n\nEmitted when the cache gets cleared.\n\n    cache.on('clear', function(size){});\n    cache.clear();\n\n## Developing\n\nThe library is published to NPM and can be installed with the following command:\n\n    $ npm install js-cache\n    \n## Building\n\nThe scripts have to be bundled in order to use them in a browser. One of the tools you can use is browserify.\n\n    $ sudo npm install browserify -g\n    $ make browserify\n    \nThis will build the script in `bundle/cache.js`\n\n## Testing\n\nNavigate to this module's repository and make sure you have the development modules installed:\n\n    $ npm install\n\n\nRun the tests:\n\n    $ npm test\n\n","_id":"js-cache@1.0.2","dist":{"shasum":"e04d6a1744f8fede1b3b875462d24343c70d3b54","tarball":"https://registry.npmjs.org/js-cache/-/js-cache-1.0.2.tgz","integrity":"sha512-NajRFY56NdIeeunTUgurYNM75q/zS0TqbEy4GmpE75yeGXnQu1PMkoNfwhTvRQBa8Zhgcxp8RrJuyK4KXTlcPw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDqWOnB71jKFYCdX9C+yhT6A4SLp5TECVaMv4EToK1KlgIgbTfnsUC8LyqGWlNqxeOJZCqMmZ8e3TMQfL/N9dPXGHo="}]},"_npmVersion":"1.1.63","_npmUser":{"name":"dirkbonhomme","email":"dirk@bytelogic.be"},"maintainers":[{"name":"dirkbonhomme","email":"dirk@bytelogic.be"}],"directories":{}},"1.0.3":{"name":"js-cache","version":"1.0.3","license":"MIT","description":"Caching library supporting timeouts, events and external data sources","keywords":["cache","memory","event"],"author":{"name":"Dirk Bonhomme","email":"dirk@bytelogic.be"},"main":"index","repository":{"type":"git","url":"git://github.com/dirkbonhomme/js-cache.git"},"scripts":{"test":"make test"},"config":{"blanket":{"pattern":"lib/cache.js"}},"dependencies":{"infinite-timeout":"*","backbone-events-standalone":"*"},"devDependencies":{"mocha":"*","expect.js":"*","sinon":"*","blanket":"git://github.com/alex-seville/blanket.git#development"},"engines":{"node":">=0.8"},"gitHead":"79002ef2d2869a66b2fc6726bbcf0e3e57725051","bugs":{"url":"https://github.com/dirkbonhomme/js-cache/issues"},"homepage":"https://github.com/dirkbonhomme/js-cache#readme","_id":"js-cache@1.0.3","_npmVersion":"5.3.0","_nodeVersion":"8.6.0","_npmUser":{"name":"dirkbonhomme","email":"dirk@bytelogic.be"},"dist":{"integrity":"sha512-1vJ8wLHuuzxbzJZxRBs51HAhlCIuO/bNROmjroBHUhoxBbhwnqBCHe2TEw2KPdW/n8qPu4+h9HZHcNZEod7jxw==","shasum":"28fdd75069c73395dbcbab63ce8d090df9505f43","tarball":"https://registry.npmjs.org/js-cache/-/js-cache-1.0.3.tgz","fileCount":10,"unpackedSize":42188,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCB327TV/+3FaSTh/mxQiM19YRGsUNboortFXABdRn3dAIgbo3+eTmAjOCPvNXV3yxB7/N00dNdJzxa+RtCeXPNFbs="}]},"maintainers":[{"name":"dirkbonhomme","email":"dirk@bytelogic.be"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/js-cache_1.0.3_1518605125542_0.5829157040076673"},"_hasShrinkwrap":false}},"readme":"# Caching library for JavaScript and Node.js\n\nCaching library with support for timeouts, events and external data sources.\n\n## Overview\n\n* [Usage in Node.js](#usage-in-nodejs)\n* [Usage in browsers](#usage-in-browsers)\n* [Instance](#instance)\n* [API](#api)\n* [External data source](#external-data-source)\n* [Events](#events)\n* [Developing](#developing)\n* [Building](#building)\n* [Testing](#testing)\n\n## Usage in Node.js  \n\n    var cache = require('js-cache');\n    cache.set('lorem', 'ipsum', 60000);\n    console.log(cache.get('lorem'));\n    \n    var myCache = new cache();\n    myCache.set('lorem', 'dolor', 60000);\n    console.log(myCache.get('lorem'));\n\n\n## Usage in browsers\n\n    <script src=\"bundle/cache.js\"></script> \n    <script>\n        cache.set('lorem', 'ipsum', 60000);\n        console.log(cache.get('lorem'));\n    </script>\n\n## Instance\n\nIt is possible to call the `cache` object directly:\n\n    cache.set('lorem', 'ipsum');\n    console.log(cache.get('lorem'));\n\nor use it as a constructor to create a separate storage:\n\n    var c2 = new cache();\n    c2.set('lorem', 'dolor');\n    console.log(c2.get('lorem'));\n\n## API\n\n### cache.set(`key`, `value`, `[ttl]`)\n\nCache data or update and existing record.\n\n`key` Unique key identifying the cache  \n`value` Cached value  \n`ttl` Time to live in milliseconds (optional) \n\n### cache.get(`key`, `[callback]`)\n\nGet cached value. Returns cached value (or undefined) if no callback was provided. Always returns undefined if callback argument is present.\n\n`key` Key identifying the cache  \n`callback` Return value in callback if record exists in memory or on external resource (optional)\n\n### cache.del(`key`)\n\nDelete cached data. Returns true if the record existed, false if not.\n\n`key` Key identifying the cache\n\n### cache.clear()\n\nClear all cached data. Returns number of cleared records.\n\n### cache.size()\n                \nReturns number of cached records.\n\n### cache.debug()\n\nReturns internal object with cached records.\n\n### cache.keys()\n\nReturns list of cached record keys.\n\n## External data source\n\nIt is possible to forward api requests to external handlers. They can be used for logging, storing in persistent database etc. The cache library will function as a temporary, in-memory layer.\n\n    var c = new cache({\n        set: setHandler,\n        get: getHandler,\n        del: delHandler,\n        clear: clearHandler\n    });\n    \nAll handlers are optional.\n    \n`setHandler` is called with `key`, `value`, `ttl` on cache.set().  \n\n`getHandler` is called with `key`, `callback` on cache.get() when a callback is provided and the key is not present in the cache. The getHandler is required to execute `callback`.  \n\n`delHandler` is called with `key` on cache.del(). It is not called when a cached record times out.  \n\n`clearHandler` is called without arguments on cache.clear().  \n\n## Events\n\nThe cache library uses the Backbone event framework. Please refer to their [documentation](http://backbonejs.org/#Events) for a detailed overview. \n\n### set , set:key\n\nEmitted when setting a value to a new record.\n\n    cache.on('set', function(key, value, ttl){});\n    cache.on('set:lorem', function(value, ttl){});\n    cache.set('lorem', 'ipsum', 123);\n    \n### update, update:key\n\nEmitted when updating the value or ttl of a known record.\n\n    cache.set('lorem', 'ipsum');\n    cache.on('update', function(key, value, ttl){});\n    cache.on('update:lorem', function(value, ttl){});\n    cache.set('lorem', 'ipsum', 123);\n\n### del, del:key\n\nEmitted when deleting a record or when a cached record times out.\n\n    cache.set('lorem', 'ipsum');\n    cache.on('del', function(key){});\n    cache.on('del:lorem', function(){});\n    cache.del('lorem');\n    \n### clear\n\nEmitted when the cache gets cleared.\n\n    cache.on('clear', function(size){});\n    cache.clear();\n\n## Developing\n\nThe library is published to NPM and can be installed with the following command:\n\n    $ npm install js-cache\n    \n## Building\n\nThe scripts have to be bundled in order to use them in a browser. One of the tools you can use is browserify.\n\n    $ sudo npm install browserify -g\n    $ make browserify\n    \nThis will build the script in `bundle/cache.js`\n\n## Testing\n\nNavigate to this module's repository and make sure you have the development modules installed:\n\n    $ npm install\n\n\nRun the tests:\n\n    $ npm test\n\n","maintainers":[{"name":"dirkbonhomme","email":"dirk@bytelogic.be"}],"time":{"modified":"2022-06-19T05:30:14.574Z","created":"2013-11-29T11:16:32.459Z","0.1.0":"2013-11-29T11:16:34.101Z","1.0.0":"2013-12-05T12:31:36.416Z","1.0.2":"2013-12-06T14:12:50.168Z","1.0.3":"2018-02-14T10:45:26.318Z"},"author":{"name":"Dirk Bonhomme","email":"dirk@bytelogic.be"},"repository":{"type":"git","url":"git://github.com/dirkbonhomme/js-cache.git"},"homepage":"https://github.com/dirkbonhomme/js-cache#readme","keywords":["cache","memory","event"],"bugs":{"url":"https://github.com/dirkbonhomme/js-cache/issues"},"license":"MIT","readmeFilename":"README.md"}