我有一个用于事务数据获取并设置为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