{"_id":"mongoose-cachebox","_rev":"45-6ac7c8f0c6d3f381906d62f0a8a68390","name":"mongoose-cachebox","description":"Cache mongoose queries in memory, redis or use your own driver","dist-tags":{"latest":"1.2.0"},"versions":{"0.1.0":{"name":"mongoose-cachebox","version":"0.1.0","description":"Cache mongoose queries in memory, redis or use your own driver","author":{"name":"Jonathan Brumley","email":"cayasso@gmail.com"},"homepage":"https://github.com/cayasso/mongoose-cachebox","main":"index.js","scripts":{"test":"make test"},"repository":{"type":"git","url":"git://github.com/cayasso/mongoose-cachebox.git"},"keywords":["plugin","mongoose","query","cache","data","mongo","mongodb","redis","store","memory","catbox","ttl"],"license":"MIT","dependencies":{"catbox":"1.0.x","debug":"0.7.x"},"devDependencies":{"mocha":"*","expect.js":"*","redis":"0.8.x","mongodb":"1.3.x","mongoose":"3.6.x"},"readme":"# mongoose cachebox\n\n[![Build Status](https://travis-ci.org/cayasso/mongoose-cachebox.png?branch=master)](https://travis-ci.org/cayasso/mongoose-cachebox)\n[![NPM version](https://badge.fury.io/js/mongoose-cachebox.png)](http://badge.fury.io/js/mongoose-cachebox)\n\nCaching [mongoose](http://http://mongoosejs.com/) queries easier with [catbox](https://github.com/spumko/catbox).\n\n## Instalation\n\n```bash\n$ npm install mongoose-cachebox\n```\n\n## Early stages be patient\n\n## Usage","readmeFilename":"README.md","bugs":{"url":"https://github.com/cayasso/mongoose-cachebox/issues"},"_id":"mongoose-cachebox@0.1.0","dist":{"shasum":"55f60cc2ca7667cac79b90cadc9293d3c0ddb3ca","tarball":"https://registry.npmjs.org/mongoose-cachebox/-/mongoose-cachebox-0.1.0.tgz","integrity":"sha512-1KZqR+1K4W4OyFuh+WKJTZe/M+38MC9WgM+n6xNK7VrWhuFBhXcAg8wLEIOqDJEQ5FsqMCNNmaeHoRRZRpaaeA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIB1+3ASt0SgCZEGw83yJ6uFpWhyeFG5AWjqlpqOq1ypiAiB/hF6DLaRnZd/PnkDMgcOtXxLrvusiCNR39VUNApQcBA=="}]},"_from":".","_npmVersion":"1.3.5","_npmUser":{"name":"cayasso","email":"cayasso@gmail.com"},"maintainers":[{"name":"cayasso","email":"cayasso@gmail.com"}],"directories":{}},"1.0.0":{"name":"mongoose-cachebox","version":"1.0.0","description":"Cache mongoose queries in memory, redis or use your own driver","author":{"name":"Jonathan Brumley","email":"cayasso@gmail.com"},"homepage":"https://github.com/cayasso/mongoose-cachebox","main":"index.js","scripts":{"test":"make test"},"repository":{"type":"git","url":"git://github.com/cayasso/mongoose-cachebox.git"},"keywords":["plugin","mongoose","query","cache","data","mongo","mongodb","redis","store","memory","catbox","ttl"],"license":"MIT","dependencies":{"catbox":"git://github.com/cayasso/catbox.git","debug":"0.7.x"},"devDependencies":{"mocha":"*","expect.js":"*","redis":"0.8.x","mongodb":"1.3.x","mongoose":"3.6.x"},"readme":"# mongoose cachebox\n\n[![Build Status](https://travis-ci.org/cayasso/mongoose-cachebox.png?branch=master)](https://travis-ci.org/cayasso/mongoose-cachebox)\n[![NPM version](https://badge.fury.io/js/mongoose-cachebox.png)](http://badge.fury.io/js/mongoose-cachebox)\n\nCaching [mongoose](http://http://mongoosejs.com/) queries easier with [catbox](https://github.com/spumko/catbox).\n\n## Instalation\n\n``` bash\n$ npm install mongoose-cachebox\n```\n\n## Usage\n\n``` javascript\nvar mongoose = require('mongoose');\n\nvar options = {\n  cache: true, // start caching\n  ttl: 30000 // 30 seconds\n};\n\n// adding mongoose cachebox\nmongooseCachebox(mongoose, options);\n```\n\nThen later any `find` query will be cached for 60 seconds.\n\nYou can also enable caching programatically by using the `cache` method directly from the query instance:\n\n``` javascript\nvar Person = mongoose.model('Person');\n\nPerson.find({ active: true })\n.cache(50000) // cache for 50 seconds\n.exec(function (err, docs) { /* ... */\n  \n  if (err) throw error;\n\n  console.log(docs.ttl) // time left for expiration in ms\n  console.log(docs.stored); // timestamp this query was cached\n\n  console.log(docs);\n\n});\n\n```\n\n## API\nThis plugin will add two more methods to a mongoose query instance `cache` and `ttl`.\n\n### query.cache([cached], [ttl])\n\nBoth parameters `cache` and `ttl` are optional, the first one is for enable caching the second is for specifying the cache expiration (time to live).\n\nFor start caching just call the `cache` method:\n\n``` javascript\nPerson.find({ active: true })\n.cache() // will enable caching with 60 seconds ttl\n.exec(function (err, docs) {\n  /* .... */\n});\n```\n\nThe above is equivalent to this:\n\n``` javascript\nPerson.find({ active: true })\n.cache(true) // start caching with 60 seconds ttl\n.exec(function (err, docs) {\n  /* .... */\n});\n```\n\nYou can specify the `ttl` (time to live) value directly:\n\n``` javascript\nPerson.find({ active: true })\n.cache(10000) // cache for 10 seconds\n.exec(function (err, docs) {\n  /* .... */\n});\n```\n\nThe above is equivalent to this:\n\n``` javascript\nPerson.find({ active: true })\n.cache(true, 10000) // enable caching with 10 seconds ttl\n.exec(function (err, docs) {\n  /* .... */\n});\n```\n\nAnd to disable caching for specific query just pass `false`:\n\n``` javascript\nPerson.find({ active: true })\n.cache(false) // stop caching this query\n.exec(function (err, docs) {\n  /* .... */\n});\n```\n\n### query.ttl(ttl)\n\nBy default the ttl value is `60000` (60 seconds) but you can use the `ttl` method to specify a different value:\n\n``` javascript\nPerson.find({ active: true })\n.cache() // cache query\n.ttl(10000) // caching for 10 seconds\n.exec(function (err, docs) {\n  /* .... */\n});\n```\n\n## Redis\n\nBy default mongoose-cachebox will use the memory engine to cache queries but it can cache queries using `Redis` by specifying redis engine when initializing the plugin:\n\n``` javascript\nvar mongoose = require('mongoose');\n\nvar options = {\n  engine: 'redis',\n  host: '127.0.0.1',\n  port: '6379',\n  password: 'secret',\n\n  cache: true, // start caching\n  ttl: 60000 // 60 seconds\n};\n\n// adding mongoose cachebox\nmongooseCachebox(mongoose, options);\n```\n\nThis module use [catbox](https://github.com/spumko/catbox) for the caching magic, so check out the project for more details and options.\n\n## Run tests\n\n``` bash\n$ make test\n```\n\n## License\n\n(The MIT License)\n\nCopyright (c) 2013 Jonathan Brumley &lt;cayasso@gmail.com&gt;\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","readmeFilename":"README.md","bugs":{"url":"https://github.com/cayasso/mongoose-cachebox/issues"},"_id":"mongoose-cachebox@1.0.0","dist":{"shasum":"81f077e1c3bd008981282195b70ae5dd0ccdc4bc","tarball":"https://registry.npmjs.org/mongoose-cachebox/-/mongoose-cachebox-1.0.0.tgz","integrity":"sha512-S+d6xrXoHzPeiM3tHxp0AHIzAp6o+ghXzcOgCiyQEBQZ6tdyqxZnzqrNZkpQsl0f94qiudz98iIyyrjSYE2MmA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIF2xx93xbKitp/uwlLop6w9jsAgozRSo88V3gyNHFJrmAiEAmz7w928rnyze0ryNjaT1XUXTew0J07qTx05FI0wi5gA="}]},"_from":".","_npmVersion":"1.3.5","_npmUser":{"name":"cayasso","email":"cayasso@gmail.com"},"maintainers":[{"name":"cayasso","email":"cayasso@gmail.com"}],"directories":{}},"1.0.1":{"name":"mongoose-cachebox","version":"1.0.1","description":"Cache mongoose queries in memory, redis or use your own driver","author":{"name":"Jonathan Brumley","email":"cayasso@gmail.com"},"homepage":"https://github.com/cayasso/mongoose-cachebox","main":"index.js","scripts":{"test":"make test"},"repository":{"type":"git","url":"git://github.com/cayasso/mongoose-cachebox.git"},"keywords":["plugin","mongoose","query","cache","data","mongo","mongodb","redis","store","memory","catbox","ttl"],"license":"MIT","dependencies":{"catbox":"git://github.com/cayasso/catbox.git","debug":"0.7.x"},"devDependencies":{"mocha":"*","expect.js":"*","redis":"0.8.x","mongodb":"1.3.x","mongoose":"3.6.x"},"readme":"# mongoose cachebox\n\n[![Build Status](https://travis-ci.org/cayasso/mongoose-cachebox.png?branch=master)](https://travis-ci.org/cayasso/mongoose-cachebox)\n[![NPM version](https://badge.fury.io/js/mongoose-cachebox.png)](http://badge.fury.io/js/mongoose-cachebox)\n\nCaching [mongoose](http://http://mongoosejs.com/) queries easier with [catbox](https://github.com/spumko/catbox).\n\n## Instalation\n\n``` bash\n$ npm install mongoose-cachebox\n```\n\n## Usage\n\n``` javascript\nvar mongoose = require('mongoose');\n\nvar options = {\n  cache: true, // start caching\n  ttl: 30000 // 30 seconds\n};\n\n// adding mongoose cachebox\nmongooseCachebox(mongoose, options);\n```\n\nThen later any `find` query will be cached for 60 seconds.\n\nYou can also enable caching programatically by using the `cache` method directly from the query instance:\n\n``` javascript\nvar Person = mongoose.model('Person');\n\nPerson.find({ active: true })\n.cache(50000) // cache for 50 seconds\n.exec(function (err, docs) { /* ... */\n  \n  if (err) throw error;\n\n  console.log(docs.ttl) // time left for expiration in ms\n  console.log(docs.stored); // timestamp this query was cached\n  console.log(docs);\n\n});\n\n```\n\n## API\n\nThis plugin will add two more methods to a mongoose query instance `cache` and `ttl`.\n\n### query.cache([cached], [ttl])\n\nBoth parameters `cache` and `ttl` are optional, the first one is for enable caching the second is for specifying the cache expiration (time to live).\n\nFor start caching just call the `cache` method:\n\n``` javascript\nPerson.find({ active: true })\n.cache() // will enable caching with 60 seconds ttl\n.exec(function (err, docs) {\n  /* .... */\n});\n```\n\nThe above is equivalent to this:\n\n``` javascript\nPerson.find({ active: true })\n.cache(true) // start caching with 60 seconds ttl\n.exec(function (err, docs) {\n  /* .... */\n});\n```\n\nYou can specify the `ttl` (time to live) value directly:\n\n``` javascript\nPerson.find({ active: true })\n.cache(10000) // cache for 10 seconds\n.exec(function (err, docs) {\n  /* .... */\n});\n```\n\nThe above is equivalent to this:\n\n``` javascript\nPerson.find({ active: true })\n.cache(true, 10000) // enable caching with 10 seconds ttl\n.exec(function (err, docs) {\n  /* .... */\n});\n```\n\nAnd to disable caching for specific query just pass `false`:\n\n``` javascript\nPerson.find({ active: true })\n.cache(false) // stop caching this query\n.exec(function (err, docs) {\n  /* .... */\n});\n```\n\n### query.ttl(ttl)\n\nBy default the ttl value is `60000` (60 seconds) but you can use the `ttl` method to specify a different value:\n\n``` javascript\nPerson.find({ active: true })\n.cache() // cache query\n.ttl(10000) // caching for 10 seconds\n.exec(function (err, docs) {\n  /* .... */\n});\n```\n\n## Redis\n\nBy default mongoose-cachebox will use the memory engine to cache queries but it can cache queries using `Redis` by specifying redis engine when initializing the plugin:\n\n``` javascript\nvar mongoose = require('mongoose');\n\nvar options = {\n  engine: 'redis',\n  host: '127.0.0.1',\n  port: '6379',\n  password: 'secret',\n\n  cache: true, // start caching\n  ttl: 60000 // 60 seconds\n};\n\n// adding mongoose cachebox\nmongooseCachebox(mongoose, options);\n```\n\nThis module use [catbox](https://github.com/spumko/catbox) for the caching magic, so check out the project for more details and options.\n\n## Run tests\n\n``` bash\n$ make test\n```\n\n## License\n\n(The MIT License)\n\nCopyright (c) 2013 Jonathan Brumley &lt;cayasso@gmail.com&gt;\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","readmeFilename":"README.md","bugs":{"url":"https://github.com/cayasso/mongoose-cachebox/issues"},"_id":"mongoose-cachebox@1.0.1","dist":{"shasum":"747a935946e2de04fe8f05a9e55765b09a97a034","tarball":"https://registry.npmjs.org/mongoose-cachebox/-/mongoose-cachebox-1.0.1.tgz","integrity":"sha512-oKdMRL31DFu1hy6mac5vwimTBQk/0qqAEUFmzrZr9J44hW+ftH6oZ7da5bTsSiM4lDkV0rqVs2tYjxHZyri7oA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC08+7nbWOrzippqDMC3myMDHSj3eVXyJ+cPPrNWCd8DAIgUZCut/PPPT+PYkrn4IhRUMVwQBNO++5I7UQegyXolOQ="}]},"_from":".","_npmVersion":"1.2.24","_npmUser":{"name":"cayasso","email":"cayasso@gmail.com"},"maintainers":[{"name":"cayasso","email":"cayasso@gmail.com"}],"directories":{}},"1.0.2":{"name":"mongoose-cachebox","version":"1.0.2","description":"Cache mongoose queries in memory, redis or use your own driver","author":{"name":"Jonathan Brumley","email":"cayasso@gmail.com"},"homepage":"https://github.com/cayasso/mongoose-cachebox","main":"index.js","scripts":{"test":"make test"},"repository":{"type":"git","url":"git://github.com/cayasso/mongoose-cachebox.git"},"keywords":["plugin","mongoose","query","cache","data","mongo","mongodb","redis","store","memory","catbox","ttl"],"license":"MIT","dependencies":{"catbox":"git://github.com/cayasso/catbox.git","debug":"0.7.x"},"devDependencies":{"mocha":"*","expect.js":"*","redis":"0.8.x","mongodb":"1.3.x","mongoose":"3.6.x"},"readme":"# mongoose cachebox\n\n[![Build Status](https://travis-ci.org/cayasso/mongoose-cachebox.png?branch=master)](https://travis-ci.org/cayasso/mongoose-cachebox)\n[![NPM version](https://badge.fury.io/js/mongoose-cachebox.png)](http://badge.fury.io/js/mongoose-cachebox)\n\nCaching [mongoose](http://http://mongoosejs.com/) queries easier with [catbox](https://github.com/spumko/catbox).\n\n## Instalation\n\n``` bash\n$ npm install mongoose-cachebox\n```\n\n## Usage\n\n``` javascript\nvar mongoose = require('mongoose');\n\nvar options = {\n  cache: true, // start caching\n  ttl: 30000 // 30 seconds\n};\n\n// adding mongoose cachebox\nmongooseCachebox(mongoose, options);\n```\n\nThen later any `find` query will be cached for 60 seconds.\n\nYou can also enable caching programatically by using the `cache` method directly from the query instance:\n\n``` javascript\nvar Person = mongoose.model('Person');\n\nPerson.find({ active: true })\n.cache(50000) // cache for 50 seconds\n.exec(function (err, docs) { /* ... */\n  \n  if (err) throw error;\n\n  console.log(docs.ttl) // time left for expiration in ms\n  console.log(docs.stored); // timestamp this query was cached\n  console.log(docs);\n\n});\n\n```\n\n## API\n\nThis plugin will add two more methods to a mongoose query instance `cache` and `ttl`.\n\n### query.cache([cached], [ttl])\n\nBoth parameters `cache` and `ttl` are optional, the first one is for enable caching the second is for specifying the cache expiration (time to live).\n\nFor start caching just call the `cache` method:\n\n``` javascript\nPerson.find({ active: true })\n.cache() // will enable caching with 60 seconds ttl\n.exec(function (err, docs) {\n  /* .... */\n});\n```\n\nThe above is equivalent to this:\n\n``` javascript\nPerson.find({ active: true })\n.cache(true) // start caching with 60 seconds ttl\n.exec(function (err, docs) {\n  /* .... */\n});\n```\n\nYou can specify the `ttl` (time to live) value directly:\n\n``` javascript\nPerson.find({ active: true })\n.cache(10000) // cache for 10 seconds\n.exec(function (err, docs) {\n  /* .... */\n});\n```\n\nThe above is equivalent to this:\n\n``` javascript\nPerson.find({ active: true })\n.cache(true, 10000) // enable caching with 10 seconds ttl\n.exec(function (err, docs) {\n  /* .... */\n});\n```\n\nAnd to disable caching for specific query just pass `false`:\n\n``` javascript\nPerson.find({ active: true })\n.cache(false) // stop caching this query\n.exec(function (err, docs) {\n  /* .... */\n});\n```\n\n### query.ttl(ttl)\n\nBy default the ttl value is `60000` (60 seconds) but you can use the `ttl` method to specify a different value:\n\n``` javascript\nPerson.find({ active: true })\n.cache() // cache query\n.ttl(10000) // caching for 10 seconds\n.exec(function (err, docs) {\n  /* .... */\n});\n```\n\n## Redis\n\nBy default mongoose-cachebox will use the memory engine to cache queries but it can cache queries using `Redis` by specifying redis engine when initializing the plugin:\n\n``` javascript\nvar mongoose = require('mongoose');\n\nvar options = {\n  engine: 'redis',\n  host: '127.0.0.1',\n  port: '6379',\n  password: 'secret',\n\n  cache: true, // start caching\n  ttl: 60000 // 60 seconds\n};\n\n// adding mongoose cachebox\nmongooseCachebox(mongoose, options);\n```\n\nThis module use [catbox](https://github.com/spumko/catbox) for the caching magic, so check out the project for more details and options.\n\n## Run tests\n\n``` bash\n$ make test\n```\n\n## License\n\n(The MIT License)\n\nCopyright (c) 2013 Jonathan Brumley &lt;cayasso@gmail.com&gt;\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","readmeFilename":"README.md","bugs":{"url":"https://github.com/cayasso/mongoose-cachebox/issues"},"_id":"mongoose-cachebox@1.0.2","dist":{"shasum":"dfa86ed2397c4c991468cb1da3c333af0cc68c3a","tarball":"https://registry.npmjs.org/mongoose-cachebox/-/mongoose-cachebox-1.0.2.tgz","integrity":"sha512-FmLqf2JwJgSPXl9eD6wDJJ1Ll6IeObNRaESqQyZI0s0pvkFEJgwLhUwXSElvryYHLcREZWfNQnSZFmNoAbpWJg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDHFuh0wFJBJ8e+74ZLWkDkuADLJ9TltbWw79U8xxU67wIgbucOAgAbwnt30dlXc/xL8oqDUUpZQ1+keorOeZQHz1E="}]},"_from":".","_npmVersion":"1.2.24","_npmUser":{"name":"cayasso","email":"cayasso@gmail.com"},"maintainers":[{"name":"cayasso","email":"cayasso@gmail.com"}],"directories":{}},"1.1.0":{"name":"mongoose-cachebox","version":"1.1.0","description":"Cache mongoose queries in memory, redis or use your own driver","author":{"name":"Jonathan Brumley","email":"cayasso@gmail.com"},"homepage":"https://github.com/cayasso/mongoose-cachebox","main":"index.js","scripts":{"test":"make test"},"repository":{"type":"git","url":"git://github.com/cayasso/mongoose-cachebox.git"},"keywords":["plugin","mongoose","query","cache","data","mongo","mongodb","redis","store","memory","catbox","ttl"],"license":"MIT","dependencies":{"cacheman":"0.1.x","debug":"0.7.x"},"devDependencies":{"mocha":"*","expect.js":"*","redis":"0.8.x","mongodb":"1.3.x","mongoose":"3.6.x"},"readme":"# mongoose cachebox\n\n[![Build Status](https://travis-ci.org/cayasso/mongoose-cachebox.png?branch=master)](https://travis-ci.org/cayasso/mongoose-cachebox)\n[![NPM version](https://badge.fury.io/js/mongoose-cachebox.png)](http://badge.fury.io/js/mongoose-cachebox)\n\nCaching [mongoose](http://http://mongoosejs.com/) queries easier with [cacheman](https://github.com/cayasso/cacheman) that supports in-memory, and Redis engines.\n\n## Instalation\n\n``` bash\n$ npm install mongoose-cachebox\n```\n\n## Usage\n\n``` javascript\nvar mongoose = require('mongoose');\n\nvar options = {\n  cache: true, // start caching\n  ttl: 30 // 30 seconds\n};\n\n// adding mongoose cachebox\nmongooseCachebox(mongoose, options);\n```\n\nThen later any `find` query will be cached for 60 seconds.\n\nYou can also enable caching programatically by using the `cache` method directly from the query instance:\n\n``` javascript\nvar Person = mongoose.model('Person');\n\nPerson.find({ active: true })\n.cache('50s') // cache for 50 seconds\n.exec(function (err, docs) { /* ... */\n  \n  if (err) throw error;\n\n  console.log(docs.ttl) // time left for expiration in ms\n  console.log(docs.stored); // timestamp this query was cached\n  console.log(docs);\n\n});\n\n```\n\n## API\n\nThis plugin will add two more methods to a mongoose query instance `cache` and `ttl`.\n\n### query.cache([cached], [ttl])\n\nBoth parameters `cache` and `ttl` are optional, the first one is for enable caching the second is for specifying the cache expiration (time to live).\n\nFor start caching just call the `cache` method:\n\n``` javascript\nPerson.find({ active: true })\n.cache() // will enable caching with 60 seconds ttl\n.exec(function (err, docs) {\n  /* .... */\n});\n```\n\nThe above is equivalent to this:\n\n``` javascript\nPerson.find({ active: true })\n.cache(true) // start caching with 60 seconds ttl\n.exec(function (err, docs) {\n  /* .... */\n});\n```\n\nYou can specify the `ttl` (time to live) value directly:\n\n``` javascript\nPerson.find({ active: true })\n.cache(10) // cache for 10 seconds\n.exec(function (err, docs) {\n  /* .... */\n});\n```\n\nThe above is equivalent to this:\n\n``` javascript\nPerson.find({ active: true })\n.cache(true, 10) // enable caching with 10 seconds ttl\n.exec(function (err, docs) {\n  /* .... */\n});\n```\n\nAnd to disable caching for specific query just pass `false`:\n\n``` javascript\nPerson.find({ active: true })\n.cache(false) // stop caching this query\n.exec(function (err, docs) {\n  /* .... */\n});\n```\n\n### query.ttl(ttl)\n\nBy default the ttl value is `60000` (60 seconds) but you can use the `ttl` method to specify a different value:\n\n``` javascript\nPerson.find({ active: true })\n.cache() // cache query\n.ttl(10) // caching for 10 seconds\n.exec(function (err, docs) {\n  /* .... */\n});\n```\n\n## Redis\n\nBy default `mongoose-cachebox` will use the memory engine to cache queries but it can cache queries using `Redis` by specifying redis engine when initializing the plugin:\n\n``` javascript\nvar mongoose = require('mongoose');\n\nvar options = {\n  engine: 'redis',\n  host: '127.0.0.1',\n  port: '6379',\n  password: 'secret'\n};\n\n// adding mongoose cachebox\nmongooseCachebox(mongoose, options);\n```\n\nThis module use [cacheman](https://github.com/cayasso/cacheman) for the caching magic, so check out the project for more details and options.\n\n## Run tests\n\n``` bash\n$ make test\n```\n\n## License\n\n(The MIT License)\n\nCopyright (c) 2013 Jonathan Brumley &lt;cayasso@gmail.com&gt;\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","readmeFilename":"README.md","bugs":{"url":"https://github.com/cayasso/mongoose-cachebox/issues"},"_id":"mongoose-cachebox@1.1.0","_from":".","dist":{"shasum":"bb39a87330a77ad222c9bbcad68ae8ab121a2ca0","tarball":"https://registry.npmjs.org/mongoose-cachebox/-/mongoose-cachebox-1.1.0.tgz","integrity":"sha512-p0ufrLoBgFAWvdDQ559qnO/aHgw1phKwHpsfG5tiBZnuX8krl1D29DnkhPk7MR2F1bLYjbp0dKyttxN53Zk5vw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDK8BCWE+lJ7Cr+jpjQP7Yg0mrjML6M5n8xKXAxaDfeBgIgT3og+V4orcTlBxK3/r7mTrotB+fuyn6z9wWjraiY/l0="}]},"_npmVersion":"1.3.14","_npmUser":{"name":"cayasso","email":"cayasso@gmail.com"},"maintainers":[{"name":"cayasso","email":"cayasso@gmail.com"}],"directories":{}},"1.2.0":{"name":"mongoose-cachebox","version":"1.2.0","description":"Cache mongoose queries in memory, redis or use your own driver","author":{"name":"Jonathan Brumley","email":"cayasso@gmail.com"},"homepage":"https://github.com/cayasso/mongoose-cachebox","main":"index.js","scripts":{"test":"make test"},"repository":{"type":"git","url":"git://github.com/cayasso/mongoose-cachebox.git"},"keywords":["plugin","mongoose","query","cache","data","mongo","mongodb","redis","store","memory","catbox","ttl"],"license":"MIT","dependencies":{"debug":"0.7.x","cacheman":"~1.x.x","cacheman-redis":"~0.1.0"},"devDependencies":{"mocha":"*","expect.js":"*","redis":"0.8.x","mongoose":"~3.6.x"},"readme":"# mongoose cachebox\n\n[![Build Status](https://travis-ci.org/cayasso/mongoose-cachebox.png?branch=master)](https://travis-ci.org/cayasso/mongoose-cachebox)\n[![NPM version](https://badge.fury.io/js/mongoose-cachebox.png)](http://badge.fury.io/js/mongoose-cachebox)\n\nCaching [mongoose](http://http://mongoosejs.com/) queries easier with [cacheman](https://github.com/cayasso/cacheman) that supports in-memory, and Redis engines.\n\n## Instalation\n\n``` bash\n$ npm install mongoose-cachebox\n```\n\n## Usage\n\n``` javascript\nvar mongoose = require('mongoose');\n\nvar options = {\n  cache: true, // start caching\n  ttl: 30 // 30 seconds\n};\n\n// adding mongoose cachebox\nmongooseCachebox(mongoose, options);\n```\n\nThen later any `find` query will be cached for 60 seconds.\n\nYou can also enable caching programatically by using the `cache` method directly from the query instance:\n\n``` javascript\nvar Person = mongoose.model('Person');\n\nPerson.find({ active: true })\n.cache('50s') // cache for 50 seconds\n.exec(function (err, docs) { /* ... */\n  \n  if (err) throw error;\n\n  console.log(docs.ttl) // time left for expiration in ms\n  console.log(docs.stored); // timestamp this query was cached\n  console.log(docs);\n\n});\n\n```\n\n## API\n\nThis plugin will add two more methods to a mongoose query instance `cache` and `ttl`.\n\n### query.cache([cached], [ttl])\n\nBoth parameters `cache` and `ttl` are optional, the first one is for enable caching the second is for specifying the cache expiration (time to live).\n\nFor start caching just call the `cache` method:\n\n``` javascript\nPerson.find({ active: true })\n.cache() // will enable caching with 60 seconds ttl\n.exec(function (err, docs) {\n  /* .... */\n});\n```\n\nThe above is equivalent to this:\n\n``` javascript\nPerson.find({ active: true })\n.cache(true) // start caching with 60 seconds ttl\n.exec(function (err, docs) {\n  /* .... */\n});\n```\n\nYou can specify the `ttl` (time to live) value directly:\n\n``` javascript\nPerson.find({ active: true })\n.cache(10) // cache for 10 seconds\n.exec(function (err, docs) {\n  /* .... */\n});\n```\n\nThe above is equivalent to this:\n\n``` javascript\nPerson.find({ active: true })\n.cache(true, 10) // enable caching with 10 seconds ttl\n.exec(function (err, docs) {\n  /* .... */\n});\n```\n\nAnd to disable caching for specific query just pass `false`:\n\n``` javascript\nPerson.find({ active: true })\n.cache(false) // stop caching this query\n.exec(function (err, docs) {\n  /* .... */\n});\n```\n\n### query.ttl(ttl)\n\nBy default the ttl value is `60000` (60 seconds) but you can use the `ttl` method to specify a different value:\n\n``` javascript\nPerson.find({ active: true })\n.cache() // cache query\n.ttl(10) // caching for 10 seconds\n.exec(function (err, docs) {\n  /* .... */\n});\n```\n\n## Redis\n\nBy default `mongoose-cachebox` will use the memory engine to cache queries but it can cache queries using `Redis` by specifying redis engine when initializing the plugin:\n\n``` javascript\nvar mongoose = require('mongoose');\n\nvar options = {\n  engine: 'redis',\n  host: '127.0.0.1',\n  port: '6379',\n  password: 'secret'\n};\n\n// adding mongoose cachebox\nmongooseCachebox(mongoose, options);\n```\n\nThis module use [cacheman](https://github.com/cayasso/cacheman) for the caching magic, so check out the project for more details and options.\n\n## Run tests\n\n``` bash\n$ make test\n```\n\n## License\n\n(The MIT License)\n\nCopyright (c) 2013 Jonathan Brumley &lt;cayasso@gmail.com&gt;\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","readmeFilename":"README.md","bugs":{"url":"https://github.com/cayasso/mongoose-cachebox/issues"},"_id":"mongoose-cachebox@1.2.0","dist":{"shasum":"e6ec5dd4d55e16bd0b94f469260a803d1f58ab39","tarball":"https://registry.npmjs.org/mongoose-cachebox/-/mongoose-cachebox-1.2.0.tgz","integrity":"sha512-LxNL/77sCo1D0ctuHo7AD3WxQSyXvdm+YvP7npCxBL/QebwJF5mZ85XcPdiS23iToy5Xf8bz9t66q8QNzlECHQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAo+bP/P6OCdd/EJ/dwp2E5ceZxuKD+msy4i28TDG9K8AiEAuS3ONzYuK6Z98KSjSiz3nr7UCrDvYZfu0AFX9JCu92E="}]},"_from":".","_npmVersion":"1.3.14","_npmUser":{"name":"cayasso","email":"cayasso@gmail.com"},"maintainers":[{"name":"cayasso","email":"cayasso@gmail.com"}]}},"readme":"# mongoose cachebox\n\n[![Build Status](https://travis-ci.org/cayasso/mongoose-cachebox.png?branch=master)](https://travis-ci.org/cayasso/mongoose-cachebox)\n[![NPM version](https://badge.fury.io/js/mongoose-cachebox.png)](http://badge.fury.io/js/mongoose-cachebox)\n\nCaching [mongoose](http://http://mongoosejs.com/) queries easier with [catbox](https://github.com/spumko/catbox).\n\n## Instalation\n\n```bash\n$ npm install mongoose-cachebox\n```\n\n## Early stages be patient\n\n## Usage","maintainers":[{"name":"cayasso","email":"cayasso@gmail.com"}],"time":{"modified":"2022-06-20T06:55:50.292Z","created":"2013-09-10T08:27:30.090Z","0.1.0":"2013-09-10T08:27:33.441Z","1.0.0":"2013-09-12T06:05:47.648Z","1.0.1":"2013-10-20T04:55:21.851Z","1.0.2":"2013-10-22T20:34:01.065Z","1.1.0":"2013-12-11T07:34:23.510Z","1.2.0":"2013-12-13T08:04:31.396Z"},"author":{"name":"Jonathan Brumley","email":"cayasso@gmail.com"},"repository":{"type":"git","url":"git://github.com/cayasso/mongoose-cachebox.git"},"users":{"nkcmr":true,"bdentino":true,"dyaa":true,"tiglek":true}}