@@ -36,15 +36,15 @@ | |||||
1.整形数字,随时间单调递增(不一定连续),长度更短,用50年都不会超过 js Number类型最大值。(默认配置 WorkerId 是6bit,自增数是6bit) | 1.整形数字,随时间单调递增(不一定连续),长度更短,用50年都不会超过 js Number类型最大值。(默认配置 WorkerId 是6bit,自增数是6bit) | ||||
2.速度更快,是传统算法的2-5倍,0.1秒可生成50万个。(i7笔记本,默认算法配置6bit+6bit) | |||||
2.速度更快,是传统雪花算法的2-5倍,0.1秒可生成50万个。(i7笔记本,默认算法配置6bit+6bit) | |||||
3.支持时间回拨处理。比如Linux服务器时间回拨1秒,本算法能自动适应生成临界时间的唯一ID。 | |||||
3.支持时间回拨处理。比如服务器时间回拨1秒,本算法能自动适应生成临界时间的唯一ID。 | |||||
4.支持手工插入新ID。当业务需要在历史时间生成新ID时,用本算法的预留位每秒能生成5000个。 | |||||
4.支持手工插入新ID。当业务需要在历史时间生成新ID时,用本算法的预留位能生成5000个每秒。 | |||||
5.漂移时对外异步发通知事件。让调用方确切知道算法漂移记录,Log并发调用量。 | |||||
5.漂移时能外发通知事件。让调用方确切知道算法漂移记录,Log并发调用量。 | |||||
6.不依赖任何外部缓存和数据库。(但WorkerId必须由外部指定) | |||||
6.不依赖任何外部缓存和数据库。(但 WorkerId 必须由外部指定) | |||||
## 性能数据 | ## 性能数据 | ||||
@@ -56,7 +56,7 @@ | |||||
## 效果 | ## 效果 | ||||
1.js Number 类型最大数值:9007199254740992,本算法在保持并发性能(5W+/0.01s)和最大64个WorkerId(6bit)的同时,能用70年才到 js Number Max 值。 | |||||
1.js Number 类型最大数值:9007199254740992,本算法在保持并发性能(5W+/0.01s)和最大64个 WorkerId(6bit)的同时,能用70年才到 js Number Max 值。 | |||||
2.增加WorkerId位数到8bit(128节点)时,15年达到 js Number Max 值。 | 2.增加WorkerId位数到8bit(128节点)时,15年达到 js Number Max 值。 | ||||
@@ -81,13 +81,13 @@ | |||||
2.采用中心化 IdGenerator 集群,给节点生成可用 Id 列表,存入 Redis 队列供节点消费。此时64个中心化节点数足够大型互联网项目使用。 | 2.采用中心化 IdGenerator 集群,给节点生成可用 Id 列表,存入 Redis 队列供节点消费。此时64个中心化节点数足够大型互联网项目使用。 | ||||
## 如何处理时间回拨 | ## 如何处理时间回拨 | ||||
1.当发生系统时间回拨的时候,算法采用过去时序的预留序数(0-5)生成新的ID。 | |||||
1.当发生系统时间回拨的时候,算法采用过去时序的预留序数生成新的ID。 | |||||
2.默认每秒可生成100个(速度可调整)。 | |||||
2.默认每秒生成100个(速度可调整)。 | |||||
3.回拨生成的ID序号,默认靠前,也可以调整为靠后。 | 3.回拨生成的ID序号,默认靠前,也可以调整为靠后。 | ||||
4.允许时间回拨至本算法预设基数(参数可调,默认大于1年)。 | |||||
4.允许时间回拨至本算法预设基数(参数可调)。 | |||||
## 能用多久 | ## 能用多久 | ||||
@@ -1,4 +1,13 @@ | |||||
using System; | |||||
/* | |||||
* 版权属于:yitter(yitter@126.com) | |||||
* 开源地址:https://gitee.com/yitter/idgenerator | |||||
* 版权协议:MIT | |||||
* 版权说明:只要保留本版权,你可以免费使用、修改、分发本代码。 | |||||
* 免责条款:任何因为本代码产生的系统、法律、政治、宗教问题,均与版权所有者无关。 | |||||
* | |||||
*/ | |||||
using System; | |||||
namespace Yitter.IdGenerator | namespace Yitter.IdGenerator | ||||
{ | { | ||||
@@ -1,4 +1,13 @@ | |||||
using System; | |||||
/* | |||||
* 版权属于:yitter(yitter@126.com) | |||||
* 开源地址:https://gitee.com/yitter/idgenerator | |||||
* 版权协议:MIT | |||||
* 版权说明:只要保留本版权,你可以免费使用、修改、分发本代码。 | |||||
* 免责条款:任何因为本代码产生的系统、法律、政治、宗教问题,均与版权所有者无关。 | |||||
* | |||||
*/ | |||||
using System; | |||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Text; | using System.Text; | ||||
@@ -1,4 +1,13 @@ | |||||
using System; | |||||
/* | |||||
* 版权属于:yitter(yitter@126.com) | |||||
* 开源地址:https://gitee.com/yitter/idgenerator | |||||
* 版权协议:MIT | |||||
* 版权说明:只要保留本版权,你可以免费使用、修改、分发本代码。 | |||||
* 免责条款:任何因为本代码产生的系统、法律、政治、宗教问题,均与版权所有者无关。 | |||||
* | |||||
*/ | |||||
using System; | |||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Text; | using System.Text; | ||||
@@ -1,4 +1,13 @@ | |||||
using System; | |||||
/* | |||||
* 版权属于:yitter(yitter@126.com) | |||||
* 开源地址:https://gitee.com/yitter/idgenerator | |||||
* 版权协议:MIT | |||||
* 版权说明:只要保留本版权,你可以免费使用、修改、分发本代码。 | |||||
* 免责条款:任何因为本代码产生的系统、法律、政治、宗教问题,均与版权所有者无关。 | |||||
* | |||||
*/ | |||||
using System; | |||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Text; | using System.Text; | ||||
@@ -1,4 +1,13 @@ | |||||
using System; | |||||
/* | |||||
* 版权属于:yitter(yitter@126.com) | |||||
* 开源地址:https://gitee.com/yitter/idgenerator | |||||
* 版权协议:MIT | |||||
* 版权说明:只要保留本版权,你可以免费使用、修改、分发本代码。 | |||||
* 免责条款:任何因为本代码产生的系统、法律、政治、宗教问题,均与版权所有者无关。 | |||||
* | |||||
*/ | |||||
using System; | |||||
using System.Threading; | using System.Threading; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
@@ -1,4 +1,13 @@ | |||||
using System; | |||||
/* | |||||
* 版权属于:yitter(yitter@126.com) | |||||
* 开源地址:https://gitee.com/yitter/idgenerator | |||||
* 版权协议:MIT | |||||
* 版权说明:只要保留本版权,你可以免费使用、修改、分发本代码。 | |||||
* 免责条款:任何因为本代码产生的系统、法律、政治、宗教问题,均与版权所有者无关。 | |||||
* | |||||
*/ | |||||
using System; | |||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Text; | using System.Text; | ||||
@@ -1,4 +1,13 @@ | |||||
using System; | |||||
/* | |||||
* 版权属于:yitter(yitter@126.com) | |||||
* 开源地址:https://gitee.com/yitter/idgenerator | |||||
* 版权协议:MIT | |||||
* 版权说明:只要保留本版权,你可以免费使用、修改、分发本代码。 | |||||
* 免责条款:任何因为本代码产生的系统、法律、政治、宗教问题,均与版权所有者无关。 | |||||
* | |||||
*/ | |||||
using System; | |||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Text; | using System.Text; | ||||
using System.Threading; | using System.Threading; | ||||