Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
egg-mongoose-cache
Advanced tools
Readme
Egg's cache plugin based on egg-mongoose and egg-redis for egg framwork
$ npm i egg-mongoose-cache --save
egg-mongoose-cache ver | egg 2.x | egg-mongoose 3.2.x |
---|---|---|
1.x | 😁 | 😁 |
0.x | ❌ | ❌ |
// {app_root}/config/plugin.js
exports.mongooseCache = {
enable: true,
package: 'egg-mongoose-cache',
};
see config/config.default.js for more detail.
egg-redis Single Client:
exports.mongooseCache = {
ttl: 600,
keyPrefix: 'mc:',
}
egg-redis Multi Clients:
exports.mongooseCache = {
instanceName: 'cache',
ttl: 300,
keyPrefix: 'mc:',
}
In controller or service, you can use find/findOne/aggregate to cache data to redis.
Use FindOne/populate, cache 60 second:
let data = await ctx.model.user.findOne({ 'username': 'user1' }).populate('userinfo').cache(60);
Use Find, cache 600 second:
let data = await ctx.model.user.find({}).limit(10).skip(5).cache();
Use Aggregate, cache 60 second and user custom key:
let data = await ctx.model.user.aggregate(myPipelines).cache(60,'myKey');
Please open an issue egg-mongoose-cache issues.
FAQs
cache module for egg-mongoose
The npm package egg-mongoose-cache receives a total of 4 weekly downloads. As such, egg-mongoose-cache popularity was classified as not popular.
We found that egg-mongoose-cache demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.