In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain in detail how to analyze the process of integrating Springsession into Redis. The content of the article is of high quality, so the editor will share it for you as a reference. I hope you will have some understanding of the relevant knowledge after reading this article.
Why use Spring-session?
In traditional stand-alone web applications, when using web containers such as tomcat/jetty, the user's session is managed by the container. The browser records the sessionId in cookie, and the container determines whether the user has a session session according to the sessionId. The limitation here is that session is stored in a web container and managed by a single server container.
But website primary key evolution, distributed applications and clustering are the trend (to improve performance). At this point, the user's request may be distributed to different servers by load, so the traditional web container management of user session session is not feasible. Unless clusters or distributed web applications can share session, although tomcat and others support this. But there are two problems with this:
Need to hack into the web container to improve the complexity of the problem
Web containers share session, and cluster machines are bound to interact with each other.
With spring-session, we can save session to nosql databases such as Redis, Mongodb and so on. This avoids the limitation of a single point of caching.
Let's do it
1. Introduction of jar package
Org.springframework.session
Spring-session-data-redis
Redis.clients
Jedis
2.9.0
2. Add the following configuration file to application.properties
# set the session storage format to redisspring.session.store-type=redisserver.servlet.session.timeout=3600#session update policy, including ON_SAVE and IMMEDIATE. The former refreshes the cache before response commit when calling # SessionRepository#save (org.springframework.session.Session) # the latter refreshes the cache spring.session.redis.flush-mode=on-savespring.session.redis.namespace=spring:session#redis configuration spring.redis.database=0spring.redis.host=10.34.51.234spring.redis.password=123456spring.redis.pool.max-active=8spring.redis.pool.max-idle=8spring.redis.pool.max-wait=-1spring.redis.pool.min-idle=0spring.redis.port=6379 whenever there are any updates
3. Configure redis server
4. Write SpringBoot program
5. Run and log in.
You can see the session message.
6. The serialization operation is not completed. But I don't think it's necessary to complete the serialization operation.
On how to integrate Springsession into Redis process parsing is shared here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.