我使用的是springboot,我不知道如何配置超时来连接redis。
目前,我的配置是:
application.yml:
spring.redis.host: myhost
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: -1StringRedisDao.java:
@Autowired
public StringRedisDao(final StringRedisTemplate template, final ObjectMapper mapper) {
if (template.getConnectionFactory() instanceof JedisConnectionFactory) {
((JedisConnectionFactory) template.getConnectionFactory()).getShardInfo().setTimeout(5000);
((JedisConnectionFactory) template.getConnectionFactory()).setTimeout(5000);
}
this.template = template;
this.mapper = mapper;
}我使用wireshark捕获数据包,我发现redis在2秒后断开连接,而不是我在上面的代码中设置的5秒。
因此,我无法执行redis查询时间超过2秒的请求。
我该怎么做呢?
发布于 2015-09-23 00:14:06
还有一个配置设置可以放在application.properties中:
spring.redis.timeout=5000https://stackoverflow.com/questions/30439378
复制相似问题