Skip to content

Commit 2c7f221

Browse files
authored
Merge pull request #4 from freebughao/main
feat: 增加了env中配置redis db 的选项
2 parents cfdbc27 + 8b55631 commit 2c7f221

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/utils/cache/redis.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,19 @@ const redisInit = async function() {
2121
const RDS_HOST = conf.redis_host;
2222
const RDS_PORT = conf.redis_port;
2323
const RDS_PWD = conf.redis_password;
24+
const RDS_DB = conf.redis_db;
2425
const RDS_OPTS = {
2526
auth_pass: RDS_PWD,
2627
};
2728

2829
if(RDS_PWD){
2930
redisClientInstance = createClient({
30-
url: `redis://:${RDS_PWD}@${RDS_HOST}:${RDS_PORT}/0`,
31+
url: `redis://:${RDS_PWD}@${RDS_HOST}:${RDS_PORT}/${RDS_DB}`,
3132
});
3233
}else{
33-
redisClientInstance = createClient({});
34+
redisClientInstance = createClient({
35+
url: `redis://${RDS_HOST}:${RDS_PORT}/${RDS_DB}`,
36+
});
3437
}
3538

3639
redisClientInstance.on('error', err => {

tlrtcapp.env

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ tl_rtc_app_redis_host=localhost
2121
tl_rtc_app_redis_port=6379
2222
## redis auth密码
2323
tl_rtc_app_redis_password=
24+
## redis db 默认0
25+
tl_rtc_app_redis_db=0
2426

2527

2628
#-----------------以下为webrtc相关配置-----------------#

0 commit comments

Comments
 (0)