fix: 修复 boss 锁状态不释放的问题

This commit is contained in:
chenkai 2023-12-25 15:50:06 +08:00
parent 1244a99c4c
commit 36d92262b7

View File

@ -31,14 +31,21 @@ export class GH {
} }
/**更改isFightBoss状态 */ /**更改isFightBoss状态 */
changeIsFightBoss(bool = false) { async changeIsFightBoss(bool = false) {
G.redis.hSet('gonghui:isFightBoss', this.data._id, bool) const key = 'gonghui:isFightBoss:' + this.data._id;
if (bool) {
await G.ioredis.setnx(key, 1);
await G.ioredis.expire(key, 1);
} else {
await G.ioredis.del(key);
}
return return
} }
/**获取isFightBoss状态 */ /**获取isFightBoss状态 */
async getIsFightBoss(): Promise<boolean> { async getIsFightBoss(): Promise<boolean> {
return await G.redis.hGet('gonghui:isFightBoss', this.data._id) || false const key = 'gonghui:isFightBoss:' + this.data._id;
return await G.ioredis.get(key)? true : false;
} }
/** /**