信息发布→ 登录 注册 退出

SpringBoot整合Redis怎么实现

发布时间:2023-05-26

点击量:

一、引入依赖 

org.springframework.bootspring-boot-starter-data-redis2.4.4

二、后台代码:

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);
    }
标签:# redis  # springboot  # 数据库中  # port  # xxx  # database  # host  # wait  # ms  # sprin  # active  # jedis  
在线客服
服务热线

服务热线

4008888355

微信咨询
二维码
返回顶部
×二维码

截屏,微信识别二维码

打开微信

微信号已复制,请打开微信添加咨询详情!