In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the operation process of springboot integrated redis cache, the content is very detailed, interested friends can refer to it, I hope it can help you.
Springboot integration redis
The following are the main steps of the collection:
Introducing redis dependencies
Configure redis connection information
Test redis in controller
Introducing redis dependencies
In the case of redis connection pool, only this dependency can be used. If redis connection pool is used, an additional common-pools must be introduced.
implementation 'org.springframework.boot:spring-boot-starter-data-redis' configure springboot connection information spring.redis.host =localhost#Note the port number, in the previous article, the port number of our host is 63379spring.redis.port=63379spring.redis.password=javastudycontroller test call /** * @Author https://www.javastudy.cloud * @CreateTime 2019/11/4 **/@RestControllerpublic class RedisController {
@Autowired private StringRedisTemplate redisTemplate;
/** * In actual development, operations on redis are usually encapsulated in a RedisTools * Redis Tools still uses StringRedisTemplate to manipulate redis * Although redis provides a lot of number types, more use cases are to convert value to json or directly to string stored in redis * @return */ @RequestMapping("redis/testRedis") public String testRedis(){ //set key to redis redisTemplate.opsForValue().set("study","javaDemo"); //remove key-value from redis String result = redisTemplate.opsForValue().get("study");
return result; }
}
Output:
In this DEMO, the redis storage and fetch is demonstrated, but no connection pool is used, so this DEMO is only for learning and small concurrency. Before high concurrency, redis connection pool is still used to manage connections and access data. Come on, boy!
About springboot integrated redis cache operation process shared here, I hope the above content can be of some help to everyone, you can learn more knowledge. If you think the article is good, you can share it so that more people can see it.
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.