{"_id":"apostrophe-query-cache","_rev":"44-6c40529013ef7d9269eb08645a852096","name":"apostrophe-query-cache","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"apostrophe-query-cache","version":"0.1.0","keywords":["apostrophe","mongodb","query","cache","cache"],"author":{"name":"P'unk Avenue LLC"},"license":"MIT","_id":"apostrophe-query-cache@0.1.0","maintainers":[{"name":"boutell","email":"boutell@boutell.com"}],"dist":{"shasum":"54ee1830573d871a8ca9e2b54204047c9aedffb6","tarball":"https://registry.npmjs.org/apostrophe-query-cache/-/apostrophe-query-cache-0.1.0.tgz","integrity":"sha512-HjhLf/E6K3+DpoYY3QF+QuPBW8uqBf7IW7NsNC1dQew/ydxkcgMOrWo7d/tW6L930LDxXog+0keH7hSTIyT1iw==","signatures":[{"sig":"MEUCIEowFWotjo+TaoewdZmhZXQTTlQ4l/+MMHuNqKBn5ph1AiEAs0y0MHaplIwd8rPxQ2ivDoRv0uKQK0njSsyZ7adplpY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"index.js","_from":".","_shasum":"54ee1830573d871a8ca9e2b54204047c9aedffb6","gitHead":"25a5fbe37968dce6bf601726b9cbf1ee0c25fad1","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"_npmUser":{"name":"boutell","email":"boutell@boutell.com"},"repository":{"url":"https://github.com/apostrophe-query-cache","type":"git"},"_npmVersion":"1.4.24","description":"Cache Apostrophe's mongodb queries, for performance. Cache is cleared automatically when writes occur.","directories":{},"dependencies":{"async":"^0.9.0","lodash":"^3.1.0"}}},"time":{"created":"2015-02-11T01:16:43.784Z","modified":"2026-01-26T19:09:54.063Z","0.1.0":"2015-02-11T01:16:43.784Z"},"author":{"name":"P'unk Avenue LLC"},"license":"MIT","keywords":["apostrophe","mongodb","query","cache","cache"],"repository":{"url":"https://github.com/apostrophe-query-cache","type":"git"},"description":"Cache Apostrophe's mongodb queries, for performance. Cache is cleared automatically when writes occur.","maintainers":[{"email":"alex@apostrophecms.com","name":"alexgilbert"},{"email":"tom@apostrophecms.com","name":"boutell"},{"email":"stuart+npm@apostrophecms.com","name":"romanek"},{"email":"robert.means1969+apostrophecms@gmail.com","name":"bodonkey"},{"email":"kerry@punkave.com","name":"colpanik"},{"email":"greg.vanbrug@gmail.com","name":"gregvanbrug"},{"email":"stuart@punkave.com","name":"stuartromanek"},{"email":"mcoppola832@gmail.com","name":"mcoppola"},{"email":"kyleejacker@gmail.com","name":"kyjoya"},{"email":"austin.starin@gmail.com","name":"austinstarin"},{"email":"grdunn@gmail.com","name":"grdunn"},{"email":"anthony@apostrophecms.com","name":"falkodev"},{"email":"abea@mailbox.org","name":"alexbea"},{"email":"matthew.mance@gmail.com","name":"mtthwmnc"},{"email":"breyell@gmail.com","name":"breyell"},{"email":"vjeudy@protonmail.com","name":"valjed"}],"readme":"# apostrophe-query-cache\n\nThis *experimental* module adds a simple MongoDB query cache to an [Apostrophe site](http://apostrophenow.org). The cache is applied to all calls to `apos.get`, which means it impacts just about all content displayed by Apostrophe.\n\nThe entire cache is invalided by any call to any method of the `pages` collection that makes a modification. This makes the cache reasonably safe, provided that you *do not use it on multicore or multi-server sites*.\n\nThis cache makes sense only if your site has become database-bound, spending most of its time waiting for MongoDB rather than doing work of its own.\n\n## Installation\n\nnpm install --save apostrophe-query-cache\n\n## Configuration\n\n```javascript\n'apostrophe-query-cache': {}\n```\n\n## Memory management\n\nSince there is no active management of how much memory the cache is using, it is automatically invalidated every 60 seconds. In most cases this is enough to keep memory usage reasonable. It is also a very crude solution; some sort of Least Recently Used strategy would be much nicer.\n\n## Overrides\n\nYou can subclass this module at the project level to change the rules for invalidating the cache. The default is that any write to the pages collection will invalidate the cache. You can change this by overriding the `invalidate` method, which receives the method name called (such as `update`), and an array containing the arguments to that method. Return `true` to invalidate the cache, `false` to leave it alone.\n\nThis example ignores any update calls that increment something with `$inc`. We found this handy on a site that incremented a page access counter on every view but didn't need to show that information instantly to the public.\n\n```javascript\nmodule.exports = cache;\n\nfunction cache(options, callback) {\n  return new cache.Construct(options, callback);\n}\n\ncache.Construct = function(options, callback) {\n\n  var self = this;\n\n  module.exports.Super.call(self, options, null);\n\n  self.invalidate = function(method, args) {\n    if (method === 'update') {\n      var action = args[1];\n      if (action && action.$inc) {\n        return false;\n      }\n    }\n    return true;\n  };\n\n  return process.nextTick(callback);\n};\n```\n\n## Stability and Compatibility\n\nThis module is compatible with Apostrophe 0.4 and 0.5. It is currently experimental but we are using it in production.\n","readmeFilename":"README.md"}