Presentation is loading. Please wait.

Presentation is loading. Please wait.

클라우드 환경에서의 session 유지처리

Similar presentations


Presentation on theme: "클라우드 환경에서의 session 유지처리"— Presentation transcript:

1 클라우드 환경에서의 session 유지처리
Spring session redis 클라우드 환경에서의 session 유지처리 작성자 : 이승환 블로그 :

2 redis란 Redis 연동방법 NoSQL 계열의 메모리기반 db이며 session정보처리에 적합하다.
Spring redis 연동 Tomcat redis 연동 2가지 방법이 있다.

3 우분투 redis server 설치 sudo add-apt-repository ppa:chris-lea/redis-server
sudo apt-get update sudo apt-get install redis-server

4 Redis server 설정 sudo nano /etc/redis/redis.conf 접근 ip주소 설정 port 설정
password 설정 재시작 sudo service redis-server restart

5 Redis 접속 확인 redis-cli –h tool에서 확인

6 Spring redis 설정 dependency
<groupId>org.springframework.session</groupId> <artifactId>spring-session-data-redis</artifactId> <version>1.3.1.RELEASE</version> <type>pom</type> </dependency> <groupId>biz.paluch.redis</groupId> <artifactId>lettuce</artifactId> <version>3.5.0.Final</version>

7 Spring redis 설정 redis-context.xml
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns=" xmlns:xsi=" xmlns:p=" xmlns:context=" xsi:schemaLocation=" context-4.0.xsd"> <context:annotation-config /> <bean class="org.springframework.session.data.redis.config.annotation.web.http.RedisHttpSessionConfiguration"/> <bean class="org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory" p:host-name=“host" p:port="6379" p:database="0" p:password=“비밀번호"/> </beans>

8 Spring redis 설정 web.xml <context-param> </context-param>
<param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/spring/appServlet/redis-context.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener>

9 Spring redis 설정 web.xml <filter> </filter>
<filter-name>springSessionRepositoryFilter</filter-name> <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> </filter> <filter-mapping> <url-pattern>/*</url-pattern> </filter-mapping>

10 사용 springSessionRepositoryFilter 통해 redis session교체되기때문에
기존에 쓰던방식되로 쓰면 된다. session.setAttribute(“key”, Object);

11 주의 DelegatingFilterProxy가 spring 버전에 따라 없을 수도 있기때문에 확인해야된다.
Redis 에 저장시 해당 객체를 직렬화를 통해 저장하기때 문에 저장하고자하는 vo,dto 객체에 Serializable 구현해 야된다.


Download ppt "클라우드 환경에서의 session 유지처리"

Similar presentations


Ads by Google