refactor: harden task authority and room mutations

This commit is contained in:
ANG-Server
2026-07-23 00:59:00 +08:00
parent 3f14230e15
commit 968a672fbd
24 changed files with 748 additions and 64 deletions

View File

@@ -134,6 +134,18 @@ export class RealRedisService implements IRedisService, OnModuleDestroy {
}
}
async setIfAbsent(key: string, value: string, ttl?: number): Promise<boolean> {
try {
const result = ttl && ttl > 0
? await this.redis.set(key, value, 'EX', ttl, 'NX')
: await this.redis.set(key, value, 'NX');
return result === 'OK';
} catch (error) {
this.logger.error(`原子设置Redis键失败: ${key}`, error);
throw error;
}
}
/**
* 获取键对应的值
*