public class SequenceIdWorker extends Object implements IdGenerator<Long>
| Constructor and Description |
|---|
SequenceIdWorker(long dataCenterId,
long workerId) |
SequenceIdWorker(long dataCenterId,
long workerId,
boolean clock,
boolean randomSequence) |
SequenceIdWorker(long dataCenterId,
long workerId,
boolean clock,
long timeOffset,
boolean randomSequence)
基于Snowflake创建分布式ID生成器
|
public SequenceIdWorker(long dataCenterId,
long workerId)
public SequenceIdWorker(long dataCenterId,
long workerId,
boolean clock,
boolean randomSequence)
public SequenceIdWorker(long dataCenterId,
long workerId,
boolean clock,
long timeOffset,
boolean randomSequence)
dataCenterId - 数据中心ID,数据范围为0~255workerId - 工作机器ID,数据范围为0~3clock - true表示解决高并发下获取时间戳的性能问题timeOffset - 允许时间回拨的毫秒量,建议5msrandomSequence - true表示使用毫秒内的随机序列(超过范围则取余)public Long nextId()
IdGeneratornextId in interface IdGenerator<Long>Copyright © 2025. All rights reserved.