SpringBoot2.x整合redis

        1.springboot整合redis相关依赖引入
            
                org.springframework.boot
                spring-boot-starter-data-redis
            

        
        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()
            
 

你可能感兴趣的:(Springboot2.x)