diff --git a/applicationServer/src/database/redis.service.ts b/applicationServer/src/database/redis.service.ts index 48453578..fa48e93b 100644 --- a/applicationServer/src/database/redis.service.ts +++ b/applicationServer/src/database/redis.service.ts @@ -26,6 +26,7 @@ class RedisService { } async getMany(keys: string[]) { + if (keys.length === 0) return keys; return await this.redis.mget(keys); } diff --git a/applicationServer/src/live/live.service.ts b/applicationServer/src/live/live.service.ts index af66ec15..388e1e44 100644 --- a/applicationServer/src/live/live.service.ts +++ b/applicationServer/src/live/live.service.ts @@ -8,9 +8,6 @@ import { Request } from 'express'; import { uploadData } from '@src/storage/storage.repository'; import { RedisService } from '@database/redis.service'; -// import { registerMockLive } from './mock/register-mock.util'; -// registerMockLive(this.live); - @Injectable() export class LiveService { constructor( diff --git a/applicationServer/src/live/mock/register-mock.util.ts b/applicationServer/src/live/mock/register-mock.util.ts index c1f93472..832c59c5 100644 --- a/applicationServer/src/live/mock/register-mock.util.ts +++ b/applicationServer/src/live/mock/register-mock.util.ts @@ -1,4 +1,9 @@ -function registerMockLive(live) { +import { RedisService } from '@database/redis.service'; +import { REDIS_LIVE_KEY, REDIS_LIVE_LIST_KEY } from '@src/constants'; + +function registerMockLive() { + const redisService = new RedisService(); + const mockBroadcastIdList = [ '872bc363-0d0c-4bde-a867-7b0edd076ad6', '9b534e89-a596-436a-b314-65cbe0ff9fab', @@ -17,20 +22,24 @@ function registerMockLive(live) { const contentCategoryList = ['music', 'talk', null, 'cook', 'mukbang']; const moodCategoryList = [null, 'calm', null, 'happy', null]; - mockBroadcastIdList.forEach((data, idx) => { - live.data.set(mockBroadcastIdList[idx], { - broadcastId: mockBroadcastIdList[idx], - broadcastPath: `${mockBroadcastIdList[idx]}`, - title: `${mockNameList[idx]}의 라이브 방송`, - contentCategory: contentCategoryList[idx], - moodCategory: moodCategoryList[idx], - tags: [`방송 ${idx}`], - thumbnailUrl: `https://kr.object.ncloudstorage.com/media-storage/${mockBroadcastIdList[idx]}/dynamic_thumbnail.jpg`, - viewerCount: 0, - userName: mockNameList[idx], - profileImageUrl: 'https://kr.object.ncloudstorage.com/funch-storage/profile/profile_default.png', - }); + mockBroadcastIdList.forEach(async (data, idx) => { + await redisService.addSetType(REDIS_LIVE_LIST_KEY, mockBroadcastIdList[idx]); + redisService.set( + `${REDIS_LIVE_KEY}${mockBroadcastIdList[idx]}`, + JSON.stringify({ + broadcastId: mockBroadcastIdList[idx], + broadcastPath: `${mockBroadcastIdList[idx]}`, + title: `${mockNameList[idx]}의 라이브 방송`, + contentCategory: contentCategoryList[idx], + moodCategory: moodCategoryList[idx], + tags: [`방송 ${idx}`], + thumbnailUrl: `https://kr.object.ncloudstorage.com/media-storage/${mockBroadcastIdList[idx]}/dynamic_thumbnail.jpg`, + viewerCount: 0, + userName: mockNameList[idx], + profileImageUrl: 'https://kr.object.ncloudstorage.com/funch-storage/profile/profile_default.png', + }), + ); }); } -export { registerMockLive }; +registerMockLive();