diff --git a/README.md b/README.md index 0b4d8e1..c9c06cb 100644 --- a/README.md +++ b/README.md @@ -29,3 +29,8 @@ db.User.find({ ... }).cache().exec(function() { ... }) ``` For more talky output add ```debug: true``` to the cacheOpts. + +For getting the lru cache object in order to have access to its API +```javascript +mongoose.getCache() +``` diff --git a/lib/cache.js b/lib/cache.js index 35477ff..4b6fed6 100644 --- a/lib/cache.js +++ b/lib/cache.js @@ -83,6 +83,9 @@ exports.install = module.exports.install = function(mongoose, options, Aggregate mongoose.Query.prototype.exec = function(arg1, arg2) { return exec.call(this, 'exec', arguments); }; + mongoose.getCache = function() { + return cache; + }; if (typeof Aggregate !== 'undefined') { Aggregate.prototype.exec = function(arg1, arg2) { return exec.call(this, 'execAggregate', arguments);