In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to use Redis and Shiro clusters". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn how to use Redis and Shiro clusters.
Specific content
If you are using a Shiro cluster now, in order to avoid access problems, you must cache all Shiro Session in the Redis database, and then the Shiro login is divided into two parts: login authentication and authorization. In order to prevent repeated login operations, two pieces of data should be cached this time: Shiro's Session processing and Shiro role information. At the same time, in order to facilitate processing, the Spring-Data framework will be used to deal with Redis.
The management of the previously used Session is done with a class configured as follows:
1. You need to define your own implementation of SessionDAO, and the implementation of this DAO is best to inherit the "EnterpriseCacheSessionDAO" parent class directly.
2. Modify the applicationContext.xml configuration file:
Then all the Session data that can be used in the distributed cluster will be saved in Redis at this time.
3. Summary
Because Shiro has its own Session implementation mechanism, such a pattern must be an inevitable choice in distributed clusters.
Course title: using Redis to serialize role and permission data
2. Specific content
Before learning Shiro, all roles and permissions were serialized to memory because it was only a single WEB, which was completed using the EHCache cache component. The specific configuration is as follows:
But now it belongs to the server cluster environment, so now if a certain role or permission is saved in the memory of a WEB server, then other servers need to make a query if they need the role or permission. Now it is also best to serialize the data of roles and permissions into Redis data, so that there is no need for repeated query processing on each WEB side. 1. First of all, if you want to serialize the data into the Redis database, you must now have a matching Cache processing class, which is CRUD. Example: define a RedisCache processing class
2. All objects of Cache interface must be processed through CacheManager. Example: define RedisCacheManager program classes
3. Modify the applicationContext.xml configuration file:
Then all the cached data of permissions and roles will be saved in the Redis database at this time.
Thank you for reading, the above is the content of "how to use Redis and Shiro clusters". After the study of this article, I believe you have a deeper understanding of how to use Redis and Shiro clusters, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.