# uuid-segment **Repository Path**: rayliang123/uuid-segment ## Basic Information - **Project Name**: uuid-segment - **Description**: 强大分布式号段链项目,内存式获取,指数式递增。 使用jdk21,springboot3.2.2 redision,mysql - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2024-01-30 - **Last Updated**: 2024-03-04 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 提前阅读 此模块使用了自定义SegmentChain方式生成分布式ID,自动兼容mybatis-plus。 只支持mysql,项目需要用到reids组件 # Getting Started ####1.创建表【cosid_segment】sql ``CREATE TABLE `cosid_segment` ( `id` int NOT NULL AUTO_INCREMENT COMMENT 'id', `business_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '业务表名', `auto_increment` bigint DEFAULT NULL COMMENT '自增序号', `is_deleted` bit(1) DEFAULT NULL COMMENT '是否删除', `create_time` datetime DEFAULT NULL COMMENT '创建时间', `update_time` datetime DEFAULT NULL COMMENT '更新时间', PRIMARY KEY (`id`) USING BTREE ) ENGINE=InnoDB AUTO_INCREMENT=90 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;`` ###2.项目pom引入依赖 `` com.acip uuid-spring-boot-starter 1.0.3 `` ###3. 1.0.3版本解决因内存式获取号段,在项目停止、重启后发生段链问题, 项目需要优雅下线才能支持此功能 #######安全距离,默认为2 segment.id.safe.distance #######预取号段数量,默认为4 segment.id.prefetching.count #######饥饿阈值,单位秒,默认为30秒 segment.id.hunger.threshold #######项目IdWorker使用自定号段链生成分布式id,默认为true segment.id.strategy.useCustom ###4. 配置 ### Reference Documentation 分布式ID生成器(CosId)设计与实现 https://www.cnblogs.com/Ahoo-Wang/p/distributed-id.html