Skip to content

Commit

Permalink
feat: 포커 결과 계산시 레디스 TTL 활용
Browse files Browse the repository at this point in the history
  • Loading branch information
w8385 committed Feb 14, 2024
1 parent c8af787 commit 1fe9743
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/poker/poker.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ export class PokerService {
}

async calc(pokerId: string) {
try {
return await this.redisClient.json.get('result_' + pokerId);
} catch (_) {}

const poker = await this.redisClient.json.get(pokerId);
const result = {
pokerId,
Expand All @@ -115,6 +119,9 @@ export class PokerService {
);
}

await this.redisClient.json.set('result_' + pokerId, '.', result);
await this.redisClient.EXPIRE('result_' + pokerId, 60 * 10);

return result;
}

Expand Down

0 comments on commit 1fe9743

Please sign in to comment.