From eae32582943f3fa3d32a0a7f96ec096c87a0b69c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=8B=E6=AD=A3=E6=97=AD?= <2944434952@qq.com> Date: Fri, 21 Sep 2018 15:08:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9sdk=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E5=A4=9Aredis=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 + README.zh_CN.md | 1 + app.js | 7 ++++++- config/config.default.js | 1 + 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 971a6c3..ea93096 100644 --- a/README.md +++ b/README.md @@ -83,6 +83,7 @@ module.exports = appInfo => { config.weappSDK = { appId: 'xxxxxxxxxxx', appSecret: 'xxxxxxxxxxxxxxxxxx', + redisDbName: 'session', // If your Configure with multi redis clients, }; return config; diff --git a/README.zh_CN.md b/README.zh_CN.md index 6b75f7f..563c0fd 100644 --- a/README.zh_CN.md +++ b/README.zh_CN.md @@ -133,6 +133,7 @@ module.exports = appInfo => { config.weappSDK = { appId: 'xxxxxxxxxxxxxxxx', appSecret: 'xxxxxxxxxxxxxxxxxx', + redisDbName: 'session', // If your Configure with multi redis clients, }; return config; diff --git a/app.js b/app.js index 3b0b54f..b3685be 100644 --- a/app.js +++ b/app.js @@ -1,14 +1,19 @@ 'use strict'; const weapp = require('./lib/index'); +const assert = require('assert'); module.exports = app => { const config = app.config.weappSDK; + // 用以支持多redis数据库 + const name = config.name; + const redis = name ? app.redis.get(name) : app.redis; + assert(redis, `redis instance [${name}] not exists`); weapp.config({ AppId: config.appId, AppSecret: config.appSecret, - Redis: app.redis, + Redis: redis, }); app.weapp = weapp; diff --git a/config/config.default.js b/config/config.default.js index 3eef772..92fabcc 100644 --- a/config/config.default.js +++ b/config/config.default.js @@ -8,4 +8,5 @@ exports.weappSDK = { appId: '', appSecret: '', + redisDbName: '', };