eggjs / eggjs/egg

egg-redis 使用clients多连接有问题

Open
#4,634 2 comments 0 reactions 0 assignees View on GitHub
Inactive
Dominant language
TypeScript
Stars
19k
Forks
1.8k
PR merge metrics
No merged PRs in 30d

Description

## What happens?
我使用egg-redis进行多个client连接,希望连接不同的redis库获取sessionId,但是只有第一个client能正常通过keys获取所有符合条件的key,第二个client.keys返回空数组,我通过medis看到client中确实有符合条件的key。

## 配置如下:
```
config.redis = {
clients: {
m: {
host: 'xxx.local',
port: 6379,
password: 'xxxxx',
db: 2
},
o: {
host: 'xxx.local',
port: 6379,
password: 'xxxxx',
db: 3
},
}
}
```
controller文件:
```
async index () {
const { app } = this
const keys1 = await app.redis.get('m').keys('B2B_APP_SESSION_*')
const keys2 = await app.redis.get('o').keys('B2B_APP_SESSION_*')
console.log('获取session', keys1, keys2) // [111, 222, 333] []
}
这里只有client1 能拿到 keys, client2 拿不到
```
请教下大家,是我的用法有问题还是其他问题?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.