-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Redis sorted set 자료구조를 활용하여 랭킹 갱신 기능 구현
- Loading branch information
1 parent
11806cb
commit 2455d70
Showing
5 changed files
with
79 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,39 @@ | ||
import { InjectRedis } from '@liaoliaots/nestjs-redis'; | ||
import { Injectable } from '@nestjs/common'; | ||
import Redis from 'ioredis'; | ||
import { BossRaidHistoryService } from 'src/boss-raid-history/boss-raid-history.service'; | ||
import { BossRaidHistory } from 'src/boss-raid-history/entities/boss-raid-history.entity'; | ||
import { UsersService } from 'src/users/users.service'; | ||
|
||
export interface RankingInfo { | ||
ranking: number; | ||
userId: number; | ||
totalScore: number; | ||
} | ||
|
||
@Injectable() | ||
export class RankService {} | ||
export class RankService { | ||
constructor( | ||
@InjectRedis() private readonly redis: Redis, | ||
private readonly bossRaidHistoryService: BossRaidHistoryService, | ||
private readonly usersService: UsersService, | ||
) {} | ||
|
||
/** | ||
* 랭킹 패치 | ||
* 순서대로 Sorted Set의 이름, 점수(score), 키(key) | ||
*/ | ||
async fetchRanking(totalScore: number, userId: number) { | ||
await this.redis.zadd('rank', totalScore, userId); | ||
} | ||
|
||
/** | ||
* 모든 랭킹 조회 | ||
*/ | ||
getAllRanking() {} | ||
|
||
/** | ||
* 나의 랭킹 조회 | ||
*/ | ||
getMyRanking(userId: number) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters