Redis系列一 - springboot 集成 redis Demo和原理

本文介绍如何通过springboot集成redis并简单介绍其原理。 @ConfigurationProperties注解 RedisAutoConfiguration redis连接池JedisConnectionFactory和redis模板类(RedisTemplate和StringRedisTemplate)
摘要由CSDN通过智能技术生成

1. 概述

本文介绍如何通过springboot集成redis并简单介绍其原理。

2. Demo和原理

2.1. application.properties

application.properties配置参数如下

spring.redis.database=0
spring.redis.host=192.168.188.7
spring.redis.password=
spring.redis.port=6379
spring.redis.pool.max-idle=8
spring.redis.pool.min-idle=0  
spring.redis.pool.max-active=8  
spring.redis.pool.max-wait=-1

备注: 如果你要使用集群redis,则可以配置以下参数spring.redis.sentinel.* 或 spring.redis.cluster.*

2.2. RedisProperties

以上参数会被自动封装到RedisProperties中: 此类被@ConfigurationProperties注解,表示从外部文件(如application.properties)注入属性值

@ConfigurationProperties(prefix = "spring.redis")
public class RedisProperties {
   
    /**
     * Database index use
  • 3
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值