Skip to content

Commit

Permalink
[feat]: 즐겨찾기 삭제 API 호출 시, Redis 캐시 적용 (#112)
Browse files Browse the repository at this point in the history
1. 아무도 즐겨찾기 하지 않는 소환사의 경우 Redis 캐시에서도 데이터가 삭제되게끔 설정
2. 테스트 코드 수정
  • Loading branch information
epitone authored Apr 3, 2022
1 parent d4b7118 commit ea6f6f8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions apps/api/src/favoriteSummoner/FavoriteSummonerApiService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ export class FavoriteSummonerApiService {
await this.summonerRecordRepository.delete(
await this.findSummonerRecordBySummonerId(summonerId),
);
await this.cacheManager.del(`summonerId:${summonerId}:win`);
await this.cacheManager.del(`summonerId:${summonerId}:lose`);
await this.cacheManager.del(`summonerId:${summonerId}:tier`);
}

private async saveCacheSummonerRecord(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,14 @@ describe('FavoriteSummonerApiService', () => {
new SummonerRecordApiQueryRepositoryStub();
favoriteSummonerApiQueryRepository =
new FavoriteSummonerApiQueryRepositoryStub();
cacheManager = new CacheStub();

const sut = new FavoriteSummonerApiService(
favoriteSummonerRepository,
summonerRecordRepository,
summonerRecordApiQueryRepository,
favoriteSummonerApiQueryRepository,
cacheManager,
);
// when
const actual = await sut.deleteFavoriteSummoner(
Expand Down
4 changes: 4 additions & 0 deletions libs/entity/test/stub/CacheManagerStub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@ export class CacheStub {
async set(): Promise<string> {
return 'OK';
}

async del(key: string): Promise<any> {
return;
}
}

0 comments on commit ea6f6f8

Please sign in to comment.