优化 redis multi 使用
This commit is contained in:
@@ -201,7 +201,6 @@ export class EntryHandler {
|
|||||||
let channelService = this.app.get('channelService');
|
let channelService = this.app.get('channelService');
|
||||||
let channel = channelService.getChannel(roleId, true);
|
let channel = channelService.getChannel(roleId, true);
|
||||||
channel.leave(roleId, sid);
|
channel.leave(roleId, sid);
|
||||||
// this.app.rpc.battle.battleRemote.kick.route(session)(roleId, this.app.get('serverId'), serverId);
|
|
||||||
this.app.rpc.chat.chatRemote.kickWorldChannel.route(session, true)(roleId, sid, serverId);
|
this.app.rpc.chat.chatRemote.kickWorldChannel.route(session, true)(roleId, sid, serverId);
|
||||||
await leaveSysChannel(roleId, sid, serverId);
|
await leaveSysChannel(roleId, sid, serverId);
|
||||||
await leaveWorldChannel(roleId, sid, serverId);
|
await leaveWorldChannel(roleId, sid, serverId);
|
||||||
|
|||||||
@@ -158,9 +158,7 @@ export async function setTeamSearchReq(roleId: string, sid: string, qualityArr:
|
|||||||
cmds.push(['sadd', getComTeamKey(quality, lvRange), getComTeamValue(roleId, sid)]);
|
cmds.push(['sadd', getComTeamKey(quality, lvRange), getComTeamValue(roleId, sid)]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const multiClient = redisClient().multi(cmds) as Redis.Multi;
|
const res = await redisClient().multi(cmds).execAsync();
|
||||||
const newMulti = promisifyAll(multiClient) as Redis.Multi;
|
|
||||||
const res = await newMulti.execAsync();
|
|
||||||
console.log('setTeamSearchReq: ', res);
|
console.log('setTeamSearchReq: ', res);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@@ -185,9 +183,7 @@ export async function rmRoleFromQueue(roleId: string, sid: string, qualityArr: A
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const multiClient = redisClient().multi(cmds) as Redis.Multi;
|
await redisClient().multi(cmds).execAsync();
|
||||||
const newMulti = promisifyAll(multiClient) as Redis.Multi;
|
|
||||||
await newMulti.execAsync();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ export function connectRedis(redisArr: string, redisPw: string) {
|
|||||||
|
|
||||||
// 转 promise
|
// 转 promise
|
||||||
const client = promisifyAll(oldRedisClient) as Redis.RedisClient;
|
const client = promisifyAll(oldRedisClient) as Redis.RedisClient;
|
||||||
|
promisifyAll(Redis.Multi.prototype);
|
||||||
client.set('hello', 'redis', Redis.print);
|
client.set('hello', 'redis', Redis.print);
|
||||||
|
|
||||||
return client;
|
return client;
|
||||||
|
|||||||
Reference in New Issue
Block a user