Redis java.util.NoSuchElementException:池已耗尽
当我试图使用Redis java.util.NoSuchElementException:池已耗尽,java,spring-boot,redis,redis-cluster,Java,Spring Boot,Redis,Redis Cluster,当我试图使用BoundedAsyncPool从cluster Redis获取密钥时,出现了此错误 java.util.concurrent.ExecutionException: java.util.NoSuchElementException: Pool exhausted - Unable to get key(xxx), Exception: java.util.NoSuchElementException: Pool exhausted 这是我的代码: private Integer
BoundedAsyncPool
从cluster Redis获取密钥时,出现了此错误
java.util.concurrent.ExecutionException: java.util.NoSuchElementException: Pool exhausted - Unable to get key(xxx), Exception: java.util.NoSuchElementException: Pool exhausted
这是我的代码:
private Integer maxTotal = 20;
private Integer maxIdle = 20;
private Integer minIdle = 10 ;
@覆盖
公共对象get(字符串键、类clazz){
CompletableFuture getResult=pool.acquire()。然后组合(连接->{
connection.setReadFrom(ReadFrom.REPLICA);
RedisAdvancedClusterAsyncCommands async=connection.async();
返回async.get(key).whenComplete((s,throwable)->pool.release(connection));
});
试一试{
字符串值=getResult.get();
if(StringUtils.isEmpty(值)){
返回null;
}
返回新的ObjectMapper().readValue(value,clazz);
}捕获(例外e){
LOG.error(e,String.format(“无法获取密钥(%s),异常:%s”,密钥,e.getMessage());
}
返回null;
}
您可以共享整个stracktrace吗?我似乎没有看到一个池。closeAsync()
用于关闭打开的轮询,它们的
@Override
public Object get(String key, Class<?> clazz) {
CompletableFuture<String> getResult = pool.acquire().thenCompose(connection -> {
connection.setReadFrom(ReadFrom.REPLICA);
RedisAdvancedClusterAsyncCommands<String, String> async = connection.async();
return async.get(key).whenComplete((s, throwable) -> pool.release(connection));
});
try {
String value = getResult.get();
if (StringUtils.isEmpty(value)) {
return null;
}
return new ObjectMapper().readValue(value, clazz);
} catch (Exception e) {
LOG.error(e, String.format("Unable to get key(%s), Exception: %s", key, e.getMessage()));
}
return null;
}