me
CargoQueue
async demo
等待
0
处理中
0
完成
0
配置
cargo queue
Cargo Size
3
Concurrency
2
Process Time
2000ms
工作原理
async cargoqueue
批量处理:等待积累到指定数量的任务后才开始处理,像货船装载货物一样高效
并发控制:可以同时处理多个批次,提高整体吞吐量
适用场景:批量数据库操作、文件上传、API 请求等需要批处理的场景
代码示例
const cargo = async.cargoQueue((tasks, cb) => {}, 3, 2);
// 批次大小3,并发数2
cargo.push({ data: 'task1' });