import { Redis } from "ioredis"; /** * ioredis相关文档:https://www.mianshigee.com/project/luin-ioredis/ */ export async function initIORedis() { console.log('connect ioredis ...'); //统一增加前缀 let sid = G.config.serverId || 0; let preKey = `${G.config.projectName}_${G.argv.serverType == 'cross' ? `corss${sid}` : sid}_`; console.log("ioredis 统一增加前缀==>",preKey); G.ioredis = new Redis(G.argv.serverType == 'cross' ? G.config.crossRedisUrl : G.config.redisUrl,{ keyPrefix: preKey, }); G.crossioredis = new Redis(G.config.crossRedisUrl,{ keyPrefix: "cross_", }); }