mc

mon-cache

mongoose cache to redis, memcached, or lru-cache

Showing:

Popularity

Downloads/wk

0

GitHub Stars

2

Maintenance

Last Commit

7yrs ago

Contributors

1

Package

Dependencies

2

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

mon-cache

mon-cache is mongoose cache to redis, memcached, or lru-cache. This utilizes the npm modules cache-client.

Initialization

lru-cache

options = {
  store: "memory"
};

require('mon-cache')(mongoose, options);

redis

options = {
  store: "redis",
  port:6379,
  host:"127.0.0.1",
  auth:"password",  // optional
  select_db: 0      // optional, default is 0
};

require('mon-cache')(mongoose, options);

memcached

options = {
  store: "memcached",
  host:"localhost:11211"
};

require('mon-cache')(mongoose, options);

additional options

options = {
  cache: false, // global option to disable caching
  ttl: 60,      // global option to set ttl(sec), default is 60 sec
  debug: true   // print logs for debug
};

Usage

Enable cache with ttl in options. If you don't set ttl, default ttl is 60 sec.

MyModel.find({ ... })
  .cache()
  .exec(function(err, result) { ... });

or

query.cache(true)             // can explicit enable (or disable) caching
query.cache(10)               // enable caching with 10 sec ttl
query.cache('thisKey')        // enable caching with default ttl and explicit key
query.cache(true, 10)         // enable caching with 10 sec ttl
query.cache(true, 10, 'key')  // enable caching with 10 sec ttl and explicit key

Changlog

  • v0.0.2 :
    support explicit key

  • v0.0.1 :
    release mon-cache

##Contact

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100
No reviews found
Be the first to rate

Alternatives

No alternatives found

Tutorials

No tutorials found
Add a tutorial