-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: redis 동작 확인을 위한 테스트 api를 추가한다.
- Loading branch information
Showing
4 changed files
with
51 additions
and
15 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ name: cd-dev-docker | |
|
||
on: | ||
push: | ||
branches: [ "dev" ] | ||
branches: [ "dev", "feat/#298" ] | ||
|
||
jobs: | ||
build: | ||
|
24 changes: 11 additions & 13 deletions
24
src/main/java/com/clova/anifriends/global/config/RedisConfig.java
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
Submodule backend-config
updated
from 313b0a to 7dcc9f
38 changes: 38 additions & 0 deletions
38
src/test/java/com/clova/anifriends/global/RedisTestController.java
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.clova.anifriends.global; | ||
|
||
import java.util.Map; | ||
import org.springframework.data.redis.core.RedisTemplate; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
public class RedisTestController { | ||
|
||
private final RedisTemplate<String, Integer> redisTemplate; | ||
|
||
public RedisTestController(RedisTemplate<String, Integer> redisTemplate) { | ||
this.redisTemplate = redisTemplate; | ||
} | ||
|
||
@PostMapping("/data") | ||
public ResponseEntity<String> setRedisData( | ||
@RequestBody(required = true) Map<String, Integer> map) throws Exception { | ||
|
||
redisTemplate.opsForValue().set(String.valueOf(map.get("key")), map.get("value")); | ||
|
||
return new ResponseEntity<>("정상 등록", HttpStatus.CREATED); | ||
} | ||
|
||
@GetMapping("/data") | ||
public ResponseEntity<Integer> getRedisData( | ||
@RequestParam(required = true) String key) { | ||
|
||
return new ResponseEntity<>(redisTemplate.opsForValue().get(key), HttpStatus.OK); | ||
|
||
} | ||
} |