//集合中已处理过的 $orderSns = $this->redis->zRange($this->sortSetKey, 0, -1); $orderSns[] = 0; $orderSns = implode("','", $orderSns); // dd($orderSns); $sql = " SELECT *o rder_sn not in('{$orderSns}'); echo $sql . PHP_EOL; $needDeal = $this->dbr->getAll($sql); foreach ($needDeal as $one) { //处理后放入集合 $this->redis->zAdd($this->sortSetKey, ['NX'], time(), $order_sn); } //一个小时之前的删除掉 $this->redis->zRemRangeByScore($this->sortSetKey, 0, time() - 3600);
zset 轮询任务不重复执行
最新推荐文章于 2022-08-29 11:05:09 发布