Package icu.congee.id.generator.combguid
Class CombGuidGenerator
java.lang.Object
icu.congee.id.generator.combguid.CombGuidGenerator
- All Implemented Interfaces:
IdGenerator
CombGuid生成器
基于RT.Comb的实现,将时间信息编码到UUID中,使其可按时间排序。 CombGuid通过重新排列标准UUID的字节,将时间戳信息放在开头,从而实现按时间排序的功能。
CombGuid结构:
- 前6字节:Unix时间戳(精确到毫秒)
- 后10字节:随机UUID数据
- Since:
- 2024-05-01
- Version:
- 1.0
- Author:
- ixiongdi
-
Constructor Details
-
CombGuidGenerator
public CombGuidGenerator()
-
-
Method Details
-
next
生成一个新的CombGuid该方法首先生成一个随机UUID,然后将当前时间戳编码到其中, 确保生成的ID既保持唯一性又具有时间顺序性。
- Returns:
- 新生成的CombGuid字符串
-
generate
Description copied from interface:IdGenerator生成一个唯一标识符。 每个实现类都应该根据其特定的生成策略来实现此方法。- Specified by:
generatein interfaceIdGenerator- Returns:
- 生成的唯一标识符,具体类型由实现类决定
-
idType
Description copied from interface:IdGenerator获取当前生成器的标识符类型此方法用于标识生成器使用的具体ID生成策略。每个实现类都应该 返回一个对应其生成策略的IdType枚举值。
- Specified by:
idTypein interfaceIdGenerator- Returns:
- 当前生成器的标识符类型
-