Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,18 @@
public class RedisConfig {

private final RedisProperties redisProperties;
@Bean
public RedisConnectionFactory redisConnectionFactory() {
return new LettuceConnectionFactory(redisProperties.getHost(), redisProperties.getPort());
}
private final RedisConnectionFactory redisConnectionFactory;

// @Bean
// public RedisConnectionFactory redisConnectionFactory() {
// return new LettuceConnectionFactory(redisProperties.getHost(), redisProperties.getPort());
// }

@Bean
public RedisTemplate<String, Object> redisTemplate() {
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
redisTemplate.setConnectionFactory(redisConnectionFactory());
// redisTemplate.setConnectionFactory(redisConnectionFactory());
redisTemplate.setConnectionFactory(redisConnectionFactory);
redisTemplate.setKeySerializer(new StringRedisSerializer());
redisTemplate.setValueSerializer(new StringRedisSerializer());
return redisTemplate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public SecurityFilterChain securityFilterChain(HttpSecurity httpSecurity) throws
.antMatchers(
"/", "/api/v1/member/login", "/api/v1/member/renew-access-token"
, "/swagger-ui.html", "/swagger-ui/**", "/v3/api-docs/**" // swagger
, "/api/test/**"
).permitAll()
.anyRequest().authenticated()
.and()
Expand Down
23 changes: 23 additions & 0 deletions src/main/java/com/tbfp/teamplannerbe/test/RedisController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.tbfp.teamplannerbe.test;

import lombok.RequiredArgsConstructor;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/api/test/redis")
@RequiredArgsConstructor
public class RedisController {

private final RedisTemplate redisTemplate;

@PostMapping("/{key}")
public void set(@PathVariable String key, @RequestBody String value) {
redisTemplate.opsForValue().set(key, value);
}
@GetMapping("/{key}")
public String get(@PathVariable String key) {
return (String) redisTemplate.opsForValue().get(key);
}
}
13 changes: 11 additions & 2 deletions src/main/resources/application-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,17 @@ spring:
user-name-attribute: id
# redis configuration
redis:
host: localhost
port: 6379
# host: localhost
# port: 6379
cluster:
nodes:
- ENC(QUHVF2B5BpHofqiaC4T5R7Pqizp3H0q8ecxxb9+D9JYN9Bf39zYQDt4rEYEMENA4pDgkVNe3MGGc1XLx/7gGfGa9NBE867bs)
- ENC(XeOR57LFf6o62GLBsKD0RU4ZFjzoSilSuAOxTadcUj7fLXBHj88iG2ebM4O6ossWYDowPCWPp8lnmCIFjfP39GdO2U8o1zbA)
- ENC(E4n6dbNNqUTTvAswftF/Jc1QgYX2PSmtTqoBMo7RHukblzn4nRI9paG8qvd0v3KZ0hz0u7NG8RJRuEbzhO5hPiScPJ4eDB4d)
- ENC(D8tqBVJ0dQQpP2RQ0PJ26vL3nkIFNP24kFV3cur1lrNoCip0zU28VMKj5BOqkOmHWEu3KMt63B4RQQDNg9ltIhIRBSGCQP7s)
- ENC(Hz1vs4HAYLfPuU71h3AoXbE4ah5GEwyDnGV6/TMlvmiZjppiM9AReM33NqaQvhSM3mNBnQlPQt4kAg03R+z7jaDi7mOgxDfL)
- ENC(DrY0jzzsvi9oQgQa06Vryk1AcMZwoZ1YqtsHwN5Xv3dBNfx6y0daEmDwWohFYKeAEErXgDzVk3prDgdjGtNMG0EPYjPe2FW+)

flyway:
enabled: true
baseline-on-migrate: true
Expand Down