开发手记:JedisConnectionException: Could not get a resource from the pool

时间:2023-03-09 03:10:40
开发手记:JedisConnectionException: Could not get a resource from the pool

对于Redis,生产环境是集群模式,测试环境是单例模式,如果在生产环境中用单例模式会报错。

解决办法,通过云配置,将配置进行自动化配置。

开发手记:JedisConnectionException: Could not get a resource from the pool

另附一份Redis配置:

#*********************Redis单节点配置************************
# Redis服务器地址
spring.redis.host=10.5.172.67
# Redis服务器连接端口
spring.redis.port= #*********************RedisCluster集群配置************************
# Redis服务器地址
spring.redis.hosts=10.30.10.169:,10.30.10.170:,10.30.10.171:,10.30.10.169:,10.30.10.170:,10.30.10.171:
# 读取超时时间(毫秒),源码:JedisConnectionFactory中在jedisCluster中设置的和timeout连接超时是一致的。
# return StringUtils.hasText(getPassword())
# ? new JedisCluster(hostAndPort, timeout, timeout, redirects, password, poolConfig)
# : new JedisCluster(hostAndPort, timeout, redirects, poolConfig);
spring.redis.sotimeout=
# 最大重试次数
spring.redis.maxAttempts=
#集群间最大跳转次数,如果不设置maxRedirects值,源码中默认为5。一般当此值设置过大时,容易报:Too many Cluster redirections
#源码是在JedisConnectionFactory中设置的new JedisCluster(hostAndPort, timeout, timeout, redirects, password, poolConfig)
spring.redis.maxRedirects= #*********************Redis通用配置************************
# Redis服务器连接密码(默认为空)
spring.redis.password= hol@
# 连接池最大连接数(使用负值表示没有限制)
spring.redis.pool.max-active=
# 连接池最大阻塞等待时间(使用负值表示没有限制),单位毫秒
spring.redis.pool.max-wait=-
# 连接池中的最大空闲连接
spring.redis.pool.max-idle=
# 连接池中的最小空闲连接
spring.redis.pool.min-idle=
# 连接池中逐出连接的最小空闲时间 默认1800000毫秒(30分钟)
spring.redis.pool.min-evictableIdleTimeMillis=
# 连接超时时间(毫秒)
spring.redis.timeout=
# redis cacheManager过期时间,单位秒,默认为0,代表永不过期
spring.redis.cacheManager.expire =