File tree Expand file tree Collapse file tree 2 files changed +40
-0
lines changed
src/main/java/com/memesphere/global/config Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -58,6 +58,9 @@ dependencies {
5858
5959 // s3 관련
6060 implementation ' org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE'
61+
62+ // redis
63+ implementation ' org.springframework.boot:spring-boot-starter-data-redis'
6164}
6265
6366tasks. named(' test' ) {
Original file line number Diff line number Diff line change 1+ package com .memesphere .global .config ;
2+
3+ import org .springframework .beans .factory .annotation .Value ;
4+ import org .springframework .context .annotation .Bean ;
5+ import org .springframework .context .annotation .Configuration ;
6+ import org .springframework .data .redis .connection .RedisConnectionFactory ;
7+ import org .springframework .data .redis .connection .lettuce .LettuceConnectionFactory ;
8+ import org .springframework .data .redis .core .RedisTemplate ;
9+ import org .springframework .data .redis .repository .configuration .EnableRedisRepositories ;
10+ import org .springframework .data .redis .serializer .StringRedisSerializer ;
11+
12+ @ Configuration
13+ @ EnableRedisRepositories
14+ public class RedisConfig {
15+
16+ @ Value ("${spring.data.redis.host}" )
17+ private String host ;
18+
19+ @ Value ("${spring.data.redis.port}" )
20+ private Integer port ;
21+
22+ @ Bean
23+ public RedisConnectionFactory redisConnectionFactory () {
24+ return new LettuceConnectionFactory (host , port );
25+ }
26+
27+ @ Bean
28+ public RedisTemplate <String , Object > redisTemplate () {
29+ RedisTemplate <String , Object > redisTemplate = new RedisTemplate <>();
30+
31+ redisTemplate .setConnectionFactory (redisConnectionFactory ());
32+ redisTemplate .setKeySerializer (new StringRedisSerializer ());
33+ redisTemplate .setValueSerializer (new StringRedisSerializer ());
34+
35+ return redisTemplate ;
36+ }
37+ }
You can’t perform that action at this time.
0 commit comments