![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Redis client(support redis protocol) based on ioredis for egg framework
npm i egg-redis --save
redis Plugin for egg, support egg application access to redis.
This plugin based on ioredis, if you want to know specific usage, you should refer to the document of ioredis.
Change ${app_root}/config/plugin.js
to enable redis plugin:
exports.redis = {
enable: true,
package: 'egg-redis',
};
Configure redis information in ${app_root}/config/config.default.js
:
Single Client
config.redis = {
client: {
port: 6379, // Redis port
host: '127.0.0.1', // Redis host
password: 'auth',
db: 0,
},
}
Multi Clients
config.redis = {
clients: {
foo: { // instanceName. See below
port: 6379, // Redis port
host: '127.0.0.1', // Redis host
password: 'auth',
db: 0,
},
bar: {
port: 6379,
host: '127.0.0.1',
password: 'auth',
db: 1,
},
}
}
Sentinel
config.redis = {
client: {
sentinels: [{ // Sentinel instances
port: 26379, // Sentinel port
host: '127.0.0.1', // Sentinel host
}],
name: 'mymaster', // Master name
password: 'auth',
db: 0
},
}
No password
Redis support no authentication access, but we are highly recommend you to use redis requirepass
in redis.conf
.
$vim /etc/redis/redis.conf
requirepass xxxxxxxxxx // xxxxxxxxxx is your password
Because it may be cause security risk, refer:
If you want to access redis with no password, use password: null
.
See ioredis API Documentation for all available options.
ioredis
versionegg-redis
using ioredis@4 now, if you want to use other version of ioredis, you can pass the instance by config.redis.Redis
:
// config/config.default.js
config.redis = {
Redis: require('ioredis'), // customize ioredis version, only set when you needed
client: {
port: 6379, // Redis port
host: '127.0.0.1', // Redis host
password: 'auth',
db: 0,
},
}
weakDependent
config.redis = {
client: {
port: 6379, // Redis port
host: '127.0.0.1', // Redis host
password: 'auth',
db: 0,
weakDependent: true, // this redis instance won't block app start
},
}
In controller, you can use app.redis
to get the redis instance, check ioredis to see how to use.
// app/controller/home.js
module.exports = app => {
return class HomeController extends app.Controller {
async index() {
const { ctx, app } = this;
// set
await app.redis.set('foo', 'bar');
// get
ctx.body = await app.redis.get('foo');
}
};
};
If your Configure with multi clients, you can use app.redis.get(instanceName)
to get the specific redis instance and use it like above.
// app/controller/home.js
module.exports = app => {
return class HomeController extends app.Controller {
async index() {
const { ctx, app } = this;
// set
await app.redis.get('instance1').set('foo', 'bar');
// get
ctx.body = await app.redis.get('instance1').get('foo');
}
};
};
Before you start to use Redis Cluster, please checkout the document first, especially confirm cluster-enabled yes
in Redis Cluster configuration file.
In controller, you also can use app.redis
to get the redis instance based on Redis Cluster.
// app/config/config.default.js
exports.redis = {
client: {
cluster: true,
nodes: [{
host: '127.0.0.1',
port: '6379',
family: 'user',
password: 'password',
db: 'db',
}, {
host: '127.0.0.1',
port: '6380',
family: 'user',
password: 'password',
db: 'db',
}]
},
};
// app/controller/home.js
module.exports = app => {
return class HomeController extends app.Controller {
async index() {
const { ctx, app } = this;
// set
await app.redis.set('foo', 'bar');
// get
ctx.body = await app.redis.get('foo');
}
};
};
Please open an issue here.
Made with contributors-img.
2.6.1 (2025-01-19)
features
9f02a13
] - feat: remove node password and db validate on cluster mode (#39) (KenyeeCheung <kenyeecheung@icloud.com>)features
3088929
] - feat: support redis path mode (#33) (QingDeng <zrl412@163.com>)others
83d5404
] - docs: fix default redis version (dead-horse <dead_horse@qq.com>)features
5fbd718
] - feat: add config.client.weakDependent (#30) (Yiyu He <dead_horse@qq.com>)others
b307f52
] - chore: test on node@12 (dead-horse <dead_horse@qq.com>)fixes
ce7e40e
] - fix: should listen redis ready event before app start (#29) (killa <killa123@126.com>)fixes
3b0fa5a
] - fix(types): add multi client support for typescript (#27) (mars <marshalys@gmail.com>)features
f062dd5
] - feat: support typescript (#23) (耐小心 <qiqizjl@qq.com>)features
ee3fda1
] - feat: support customize ioredis version (#21) (Yiyu He <dead_horse@qq.com>)fixes
fbfbbfa
] - fix: show real redis server time by TIME command (#20) (fengmk2 <fengmk2@gmail.com>)others
70e85e2
] - chore: add package.files (dead-horse <dead_horse@qq.com>)45585e8
] - chore: update dependencies and fix ci (#16) (Yiyu He <dead_horse@qq.com>)8b88641
] - refactor: use async function (#15) (QIAO <445271466@qq.com>)8dd3776
] - deps: Update ioredis (#14) (thegatheringstorm <tgs@tgs.blue>)59d9579
] - docs: fix some typo (#13) (kyle <succpeking@hotmail.com>)de17719
] - docs:add nopassword doc (#12) (Adams <jtyjty99999@126.com>)5b0dd99
] - chore:bump to 1.0.2 (jtyjty99999 <jtyjty99999@126.com>),FAQs
Redis plugin for egg
The npm package egg-redis receives a total of 3 weekly downloads. As such, egg-redis popularity was classified as not popular.
We found that egg-redis demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.