1234567891011121314151617181920212223 |
- var Redis = require('ioredis');
- var configs = require('../../conf/config.inc.js');
- var oujRedis = {};
- var map = {};
- /**
- * 初始化Redis对象
- * @param cacheKey
- * @return {Redis}
- */
- oujRedis.init = function(cacheKey) {
- cacheKey = cacheKey || 'default';
- if (!map[cacheKey]) {
- var redisInfo = configs.redisInfo;
- redisInfo[cacheKey]['lazyConnect'] = true;
- map[cacheKey] = new Redis(redisInfo[cacheKey]);
- }
- return map[cacheKey];
- }
- module.exports = oujRedis;
|