1.0.4 • Published 6 years ago

cache-mongodbredis v1.0.4

Weekly downloads
-
License
ISC
Repository
-
Last release
6 years ago

使用步骤

  • 1.使用时需要下载好所需依赖Mongoose(4.11)与Redis(2.8)模块
  • 2.直接使用引入在项目中后,实例化对象后传入三个参数,mongose对象,redis连接返回的client的对象,缓存在redis中的存活时间
  • 3.之后就可以按照mongoose的原生方式来连接数据库、操作数据库
  • 4.调用exec方法后就会为当前调用的方法在redis中添加缓存
const mongoose = require("mongoose");
const redis = require("redis");
const client = redis.createClient(6379,"39.106.174.151");
require("cache-mongodbredis")(mongoose,client,100)

注意事项

当前模块缓存是根据方法名及其参数生成的缓存策略,并且当前相同的方法调用的数据变更后会自动更新缓存

原理

主要原理是重写了mongoose中的exec方法,并且充分利用了node异步非阻塞的策略对缓存的及时更新与生成

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago