军团活动:修复粮草先行

This commit is contained in:
luying
2021-03-30 18:07:04 +08:00
parent ba5e139bee
commit 0d7a873a34
16 changed files with 202 additions and 104 deletions
+6 -2
View File
@@ -607,7 +607,11 @@ async function generateUnionRank(key: string, serverId: number, timelen = 10) {
let pow = Math.pow(10, timelen + 1);
await redisClient().zunionstoreAsync(unionKey, 2, originKey, timeKey, 'WEIGHTS', pow, 1);
await redisClient().expireAsync(unionKey, 10); // 10秒更新一次
if(originKey.indexOf(REDIS_KEY.RACE_ACTIVITY) == -1) {
await redisClient().expireAsync(unionKey, 10); // 10秒更新一次
} else {
await redisClient().expireAsync(unionKey, 1); // 1秒更新一次
}
}
return unionKey;
}
@@ -621,7 +625,7 @@ async function generateUnionRank(key: string, serverId: number, timelen = 10) {
export async function getUnionRank(key: string, serverId: number, roleId: string, timelen = 10, limit = 100) {
let ranks = [], myRank = null;
let unionKey = await generateUnionRank(key, serverId);
let unionKey = await generateUnionRank(key, serverId, timelen);
const rankFromDb = await redisClient().zrevrangebyscoreAsync(unionKey, '+inf', '-inf', "WITHSCORES", "LIMIT", 0, limit);
let _key = key.split(':')[0];