Skip to content

pedreviljoen/mongoose-redis-caching

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mongoose-redis-caching

Simple and efficient mongoose redis caching solution

Package version License npm downloads CircleCI Greenkeeper badge code style: prettier Known Vulnerabilities

Package Quality

About

A simple Mongoose Redis caching module.

Installation

npm i mongoose-redis-caching

OR

yarn add mongoose-redis-caching

Usage

Require in the module

const mongoose = require("mongoose");
const mongooseRedisCaching = require("mongoose-redis-caching");

Configure your mongoose caching instance

mongooseRedisCaching(mongoose);

Add your own Redis URL to your .env file. The default is set to your local redis instance.

Then use as below (with Caching & no compression):

const blogs = await Blog.find({ _user: req.user.id }).cache();

With time expiration (in seconds, default is 60 sec):

const blogs = await Blog.find({ _user: req.user.id }).cache(15);

Use as below (without Caching):

const blogs = await Blog.find({ _user: req.user.id });

License

MIT

Coming soon

  • Expire items

About

A simple caching solution for Mongoose working with Redis.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •