use of com.lcache.extend.handle.redis.lettuce.pipeline.LettucePipelineExecutor in project lcache by long172066912.
the class AbstractLettuceHandleExecutor method pSync.
/**
* Lettuce管道需要使用新的连接
*
* @param commands
* @return
*/
@Override
public List<Object> pSync(List<PipelineCmd> commands) {
// 设置使用方式为管道
CacheConfigModel pipelineCacheConfigModel = new CacheConfigModel(this.getCacheConfigModel(), UseTypeEnum.PIPELINE);
// 获取管道专用链接
StatefulConnection statefulConnection = this.getStatefulConnection(new ConnectResource().setConnectResource(this.getPipelineConnectResource(pipelineCacheConfigModel)));
try {
List<Object> res = new ArrayList<>();
List<RedisFuture<?>> redisFutures = new LettucePipelineExecutor(this.async(statefulConnection)).pSync(commands);
for (int i = 0; i < redisFutures.size(); i++) {
try {
res.add(redisFutures.get(i).get());
} catch (Exception e) {
CacheExceptionFactory.addErrorLog("AbstractLettuceHandleExecutor->pSync get error ! size:" + i, e);
}
}
return res;
} finally {
// 关闭连接
// connectionResource.close();
}
}
Aggregations