Skip to content
This repository has been archived by the owner on Aug 13, 2022. It is now read-only.

Commit

Permalink
Add Redis적용 (세션처리)
Browse files Browse the repository at this point in the history
  • Loading branch information
phantom08266 committed May 9, 2021
1 parent 6ab6d59 commit 7267586
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
24 changes: 24 additions & 0 deletions src/main/java/com/dev/careers/config/RedisConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.dev.careers.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
import org.springframework.data.redis.repository.configuration.EnableRedisRepositories;

@Configuration
@EnableRedisRepositories
public class RedisConfig {

@Value("${spring.redis.host}")
private String redisHost;

@Value("${spring.redis.port}")
private int redisProt;

@Bean
public RedisConnectionFactory redisConnectionFactory(){
return new LettuceConnectionFactory(redisHost,redisProt);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import com.dev.careers.service.error.ViolationException;
import java.util.Optional;
import javax.servlet.http.HttpSession;
import org.springframework.stereotype.Component;
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;

@Component
@EnableRedisHttpSession
public class SessionAuthenticator {

public final static String SESSION_NAME = "userID";
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ server.servlet.session.timeout=3600

logging:
config: classpath:log4j2.xml

spring.session.store-type=redis
spring.redis.host=localhost
spring.redis.port=6379

0 comments on commit 7267586

Please sign in to comment.