
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
egg-cache-9
Advanced tools
The plugin implements an easy-to-use caching function based on node-cache-9, which supports caching data into memory and caching data to redis.
$ npm i egg-cache-9 --save
// {app_root}/config/plugin.js
exports.cache9 = {
enable: true,
package: 'egg-cache-9',
};
// {app_root}/config/config.default.js
exports.cache9 = {
client: {
class: 'memory',
ttl: 300,
}
};
// {app_root}/app/****.js
const cache = app.cache9;
// get data from a data source or cache
let data = await cache.get('key', async ()=>{ /* get data from data source and return it */ });
cache.renew('key'); // update expiration time
await cache.clear('key'); // clear cache
// get a lot of datas from a data source or cache
let {list, json} = await cache.getM('key', ids, obj=>obj.id, async (lst)=>{ /* get data from data source and return it */ });
cache.renewM('key', ids); // update expiration time
await cache.clearM('key', ids); //clear cache
await cache.clearM('key'); //clear cache
// {app_root}/config/config.default.js
exports.cache9 = {
default: {
ttl: 300,
},
clients: {
cacheA: {
class: 'memory',
},
cacheB: {
class: 'redis',
rds: { host: '127.0.0.1' }
}
}
};
// {app_root}/app/****.js
const cacheA = app.cache9.get('cacheA');
const cacheB = app.cache9.get('cacheB');
// get data from a data source or cache
let data = await cacheA.get('key', async ()=>{ /* get data from data source and return it */ });
cacheA.renew('key'); // update expiration time
await cacheA.clear('key'); //clear cache
// get a lot of datas from a data source or cache
let {list, json} = await cacheB.getM('key', ids, obj=>obj.id, async (lst)=>{ /* get data from data source and return it */ });
cacheB.renewM('key', ids); // update expiration time
await cacheB.clearM('key', ids); //clear cache
await cacheB.clearM('key'); //clear cache
see node-cache-9 for more detail.
When using the egg-redis plugin, you can specify the redis client directly in the configuration.
exports.cache9 = {
default: {
ttl: 300,
},
clients: {
cacheA: { // The memory cache needs to set both pubRedis and subRedis as string
class: 'memory',
pubRedis: 'cachePub', // app.redis.get('cachePub')
subRedis: 'cacheSub', // app.redis.get('cacheSub')
},
cacheB: { // redis cache can set redis as string
class: 'redis',
redis: 'cache', // app.redis.get('cache')
},
cacheC: { // If you have not configured getRedis, redis and rds, use app.redis
class: 'redis',
}
}
};
see config/config.default.js for more detail.
Run redis-server in localhost first
npm run test
FAQs
An easy-to-use egg cache plugin based on node-cache-9
We found that egg-cache-9 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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.