PHP8.1.21版本已发布
vue8.1.21版本已发布
jquery8.1.21版本已发布

SpringBoot整合Redis怎么实现

WBOY
WBOY 转载
2023-05-26 22:31:30 562浏览

一、引入依赖 

SpringBoot整合Redis怎么实现

<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-<a  style="max-width:90%" href="https://m.php.cn/zt/15737.html" target="_blank">redis</a></artifactId><version>2.4.4</version></dependency>

二、后台代码:

spring.redis.database=0
spring.redis.host=192.168.1.xxx
spring.redis.port=8099
spring.redis.jedis.pool.max-active=8
spring.redis.jedis.pool.max-wait=-1ms
spring.redis.jedis.pool.max-idle=8
spring.redis.jedis.pool.min-idle=0
spring.redis.timeout=0
@Controller
@Api(tags = "书本数据接口")
@EnableCaching//开启缓存public class BookController {

}
  @Cacheable(value = "book_id")//使用缓存    @Overridepublic Book getBookById(Integer id) {
        System.out.println("从数据库中查询。。。。。");return bookMapper.getBookById(id);
    }
声明:本文转载于:亿速云,如有侵犯,请联系admin@php.cn删除