SpringBoot2.x整合redis

        1.springboot整合redis相关依赖引入
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-data-redis</artifactId>
            </dependency>
        
        2、相关配置文件配置
            #=========redis基础配置=========
            spring.redis.database=0
            spring.redis.host=127.0.0.1
            spring.redis.port=6390
            # 连接超时时间 单位 ms(毫秒)
            spring.redis.timeout=3000

            #=========redis线程池设置=========
            # 连接池中的最大空闲连接,默认值也是8。
            spring.redis.pool.max-idle=200

            #连接池中的最小空闲连接,默认值也是0。
            spring.redis.pool.min-idle=200
            
            # 如果赋值为-1,则表示不限制;pool已经分配了maxActive个jedis实例,则此时pool的状态为exhausted(耗尽)。
            spring.redis.pool.max-active=2000

            # 等待可用连接的最大时间,单位毫秒,默认值为-1,表示永不超时
            spring.redis.pool.max-wait=1000

        4、常见redistemplate种类讲解和缓存实操(使用自动注入)

            1、注入模板
            @Autowired
            private StirngRedisTemplate strTplRedis

            2、类型String,List,Hash,Set,ZSet
            对应的方法分别是opsForValue()、opsForList()、opsForHash()、opsForSet()、opsForZSet()
            
 

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值