Skip to content

Commit

Permalink
Merge pull request #182 from twenty-three-23/feature/TT-118-Redis-Set…
Browse files Browse the repository at this point in the history
…ting

TT-118 redis setting
  • Loading branch information
snacktime81 authored Jul 10, 2024
2 parents ff61449 + cd567ff commit e154e28
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,4 @@ public interface CacheService {
List<Long> findAllByUserKey(String userKey);

RedisSentenceDTO findByKey(Long sentenceId);

void setKeySentenceIdValueSentenceInformations(Long sentenceId, RedisSentenceDTO redisSentence);
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,15 @@ public void saveSentenceInfo(Long sentenceId, RedisSentenceDTO redisSentence){
throw new RuntimeException("Error saving redisSentence List: " + sentenceId);
}
}

@Override
public List<Long> findAllByUserKey(String userKey) {
return List.of();
}

@Override
public RedisSentenceDTO findByKey(Long sentenceId) {
return null;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.twentythree.peech.common.dto.request.GPTRequest;
import com.twentythree.peech.common.dto.response.GPTResponse;
import com.twentythree.peech.script.cache.CacheService;
import com.twentythree.peech.script.domain.*;
import com.twentythree.peech.script.dto.*;
import com.twentythree.peech.script.dto.response.MajorScriptsResponseDTO;
Expand Down Expand Up @@ -38,7 +39,7 @@ public class ScriptService {
private final ThemeRepository themeRepository;
private final VersionRepository versionRepository;
private final SentenceRepository sentenceRepository;
private final ScriptInMemoryRepository scriptRedisRepository;
private final CacheService scriptRedisRepository;

@Transactional
public SaveScriptDTO saveInputScript(Long themeId, String[] paragraphs) {
Expand Down Expand Up @@ -206,11 +207,11 @@ public ModifyScriptResponseDTO modifyScriptService(List<ParagraphDTO> modifiedPa
Long newSentenceId = redisSentenceMap.getKey().getSentenceId();
RedisSentenceDTO newSentence = redisSentenceMap.getValue();

scriptRedisRepository.setKeySentenceIdValueSentenceInformations(newSentenceId, newSentence);
scriptRedisRepository.saveSentenceInfo(newSentenceId, newSentence);
newSentenceIds.add(newSentenceId);

}
scriptRedisRepository.setKeyUserValueSentenceIds("user"+userId, newSentenceIds);
scriptRedisRepository.saveSentencesIdList("user"+userId, newSentenceIds);

}
return new ModifyScriptResponseDTO(modifiedParagraphList);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.twentythree.peech.script.cache.RedisTemplateImpl;
import com.twentythree.peech.script.dto.SaveRedisSentenceInfoDto;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
Expand Down Expand Up @@ -39,6 +40,7 @@ public class ScriptRedisTemplateImplTest {
}

@Test
@Disabled
public void 문장_정보_저장() throws Exception {
List<SaveRedisSentenceInfoDto> sentencesInfoList = List.of(
new SaveRedisSentenceInfoDto(1L, 1L, 1L, "sentence1", 1L, LocalTime.of(0, 0, 12), false),
Expand Down

0 comments on commit e154e28

Please sign in to comment.