HJ_Server/src/ioredis.ts
2023-12-27 14:17:10 +08:00

23 lines
653 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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_",
});
}