java redis 超时_java - Redis忙时读取超时异常 - 堆栈内存溢出

我有一个用于事务数据获取并设置为Redis缓存的Spring Boot应用程序。 该应用程序每天的交易量为1000万。 我们的redis实例具有默认配置,并且没有哨兵,并且集群配置已禁用。 日常事务正在按预期方式进行和从redis获取。 我也有一个简单的rest控制器,用于删除数据并在持久化数据后重做。 当我在运行时调用此api时出现读取超时异常。 我正在使用jedis客户端连接到Redis。

我的redis配置类就像;

public class RedisConfiguration {

@Autowired

Environment environment;

@Bean

public RedisTemplate redisTemplate() {

RedisTemplate template = new RedisTemplate<>();

template.setConnectionFactory(jedisConnectionFactory());

return template;

}

@Bean

JedisConnectionFactory jedisConnectionFactory() {

String host = environment.getProperty("redis.host");

String portStr = environment.getProperty("redis.port");

int port=6379;

if(portStr!=null) {

port=Integer.valueOf(portStr);

}

String passwordStr = environment.getProperty("redis.password");

RedisPassword password = RedisPassword.of(passwordStr);

RedisStandaloneConfiguration redisStandaloneConfiguration = new RedisStandaloneConfiguration(host,port);

redisStandaloneConfiguration.setPassword(password);

return new JedisConnectionFactory(redisStandaloneConfiguration);

}

}

当我调用以下代码行时发生异常;

public void lastSixMonthAmountCacheScheduler() {

cacheRepository.deleteAll();

}

我正在使用默认的连接池配置。 在属性中只有redis连接主机端口用户名和密码信息。 当我调用上述方法时,出现以下错误;

org.springframework.data.redis.RedisConnectionFailureException: java.net.SocketTimeoutException: Read timed out; nested exception is redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketTimeoutException: Read timed out

at org.springframework.data.redis.connection.jedis.JedisExceptionConverter.convert(JedisExceptionConverter.java:67)

at org.springframework.data.redis.connection.jedis.JedisExceptionConverter.convert(JedisExceptionConverter.java:41)

at org.s

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值