diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2024-01-24 13:51:16 +0900 |
|---|---|---|
| committer | syuilo <Syuilotan@yahoo.co.jp> | 2024-01-24 13:51:16 +0900 |
| commit | 908e0f3b8bb128bf21f23c7e4af5a838ebc612aa (patch) | |
| tree | 836636e97d805e04d47ae86eaf1d699ee21a9ba9 /packages/backend/src/core/ReversiService.ts | |
| parent | enhance(reversi): tweak MATCHING_TIMEOUT_MS (diff) | |
| download | sharkey-908e0f3b8bb128bf21f23c7e4af5a838ebc612aa.tar.gz sharkey-908e0f3b8bb128bf21f23c7e4af5a838ebc612aa.tar.bz2 sharkey-908e0f3b8bb128bf21f23c7e4af5a838ebc612aa.zip | |
perf(reversi): set expire matchSpecific and matchAny
Diffstat (limited to 'packages/backend/src/core/ReversiService.ts')
| -rw-r--r-- | packages/backend/src/core/ReversiService.ts | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/packages/backend/src/core/ReversiService.ts b/packages/backend/src/core/ReversiService.ts index 923ccc5a64..699b312949 100644 --- a/packages/backend/src/core/ReversiService.ts +++ b/packages/backend/src/core/ReversiService.ts @@ -125,7 +125,10 @@ export class ReversiService implements OnApplicationShutdown, OnModuleInit { } //#endregion - this.redisClient.zadd(`reversi:matchSpecific:${targetUser.id}`, Date.now(), me.id); + const redisPipeline = this.redisClient.pipeline(); + redisPipeline.zadd(`reversi:matchSpecific:${targetUser.id}`, Date.now(), me.id); + redisPipeline.expire(`reversi:matchSpecific:${targetUser.id}`, 120, 'NX'); + redisPipeline.exec(); this.globalEventService.publishReversiStream(targetUser.id, 'invited', { user: await this.userEntityService.pack(me, targetUser), @@ -186,7 +189,10 @@ export class ReversiService implements OnApplicationShutdown, OnModuleInit { return game; } else { - await this.redisClient.zadd('reversi:matchAny', Date.now(), me.id); + const redisPipeline = this.redisClient.pipeline(); + redisPipeline.zadd('reversi:matchAny', Date.now(), me.id); + redisPipeline.expire('reversi:matchAny', 120, 'NX'); + await redisPipeline.exec(); return null; } } |