如何解决如何在 Zendframework 中使用 PHP 7 在 MongoDB 中编写不同的查询
控制器
$db->imran_Standard->distinct("technicalCommitte",array("stanadardType"=>$standardtype_value_list)); // 在模型数据库中 公共函数 getcreteria($email) { $records=array();
private Timer timer = new Timer(); // I start the job in a timer.
private Random rand = new Random();
private List<String> ids = getIds(); // get redis keys.
private ForkJoinPool updateThreadsPool = new ForkJoinPool(32);
timer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
ForkJoinTask<List<List<Item>>> asyncTask = updateThreadsPool.submit(() -> {
return ids.parallelStream().map(id -> getFromRedis(id)).collect(Collectors.toList());
});
int totalNum = 0;
List<Item> totalItems = new ArrayList<>();
try {
totalNum = asyncTask.get().stream().peek(totalItems::addAll)
.reduce(0,(num,list) -> num + list.size(),Integer::sum);
} catch (Exception e) { // do something }
int randIndex = rand.nextInt(totalNum); // this is where it throws exception.
// says that totalNum is zero.
// I'm pretty sure totalItems is not empty,because I print log for that.
// I tried use int totalNum = totalItems.size(),but I got the same problem.
}
},1000L,1000L
);
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。