Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mongoose-with-redis

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongoose-with-redis

Cache your Mongoose MongoDB query results with Redis

  • 0.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

This project borrowed from mongoose-redis-cache. The difference is that this project using javascript alternative coffeescript, support custom redis client, and change some internal logics and using methods.

Installation

`npm install mongoose-with-redis

Example Usage

var mongoose = require('mongoose');
var redis = require('ioredis');
var MongooseRedis = require('mongoose-with-redis');
// custom schema and model as usual
var userSchama = new mongoose.Schema({
  name: String,
  age: Number,
});
User = mongoose.model('User', userSchama);

var redisClient = redis.createClient();
mongoose.connect('mongodb://localhost/mongoose-redis-test');

// The follwing is default config if you pass no cacheOptions.
var cacheOptions = {
  cache: true,
  expires: 60,
  prefix: 'RedisCache'
};
MongooseRedis(mongoose, redisClient, cacheOptions);

// Works with lean() and exec(), the same query will use redis cache next time.
var user = yield User.findOne({name: 'xxx'}).lean().exec();
// It won't work when lack lean() or exec().
var user = yield User.findOne({name: 'xxx'}).exec();
// We will also set cacheOption in each query statement
// It won't affect other queries.
var user = yield User.findOne({name: 'xxx'})
    .setOptions({cacheOptions: {cache: false}})
    .lean().exec();

Keywords

FAQs

Package last updated on 09 Aug 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc