Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
yitter
雪花ID全家桶(SnowFlake IdGenerator)
提交
2f3924ee
雪
雪花ID全家桶(SnowFlake IdGenerator)
项目概览
yitter
/
雪花ID全家桶(SnowFlake IdGenerator)
11 个月 前同步成功
通知
201
Star
3
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
雪
雪花ID全家桶(SnowFlake IdGenerator)
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2f3924ee
编写于
4月 07, 2021
作者:
微
微希夷
提交者:
yitter
4月 07, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
!5 更严格的默认参数配置和校验
上级
d2022b0c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
6 addition
and
9 deletion
+6
-9
PHP/php_snowdrift.h
PHP/php_snowdrift.h
+0
-1
PHP/snowdrift.c
PHP/snowdrift.c
+2
-7
PHP/src/snowflake/snowflake.c
PHP/src/snowflake/snowflake.c
+4
-1
未找到文件。
PHP/php_snowdrift.h
浏览文件 @
2f3924ee
...
...
@@ -54,7 +54,6 @@ ZEND_BEGIN_MODULE_GLOBALS(snowdrift)
uint8_t
Method
;
uint64_t
BaseTime
;
uint8_t
WorkerId
;
uint8_t
WorkerIdNum
;
uint8_t
WorkerIdBitLength
;
uint8_t
SeqBitLength
;
uint32_t
MaxSeqNumber
;
...
...
PHP/snowdrift.c
浏览文件 @
2f3924ee
...
...
@@ -43,11 +43,10 @@ PHP_INI_BEGIN()
STD_PHP_INI_ENTRY
(
"snowdrift.Method"
,
"1"
,
PHP_INI_SYSTEM
,
OnUpdateLongGEZero
,
Method
,
zend_snowdrift_globals
,
snowdrift_globals
)
STD_PHP_INI_ENTRY
(
"snowdrift.BaseTime"
,
"1582136402000"
,
PHP_INI_SYSTEM
,
OnUpdateLongGEZero
,
BaseTime
,
zend_snowdrift_globals
,
snowdrift_globals
)
STD_PHP_INI_ENTRY
(
"snowdrift.WorkerId"
,
"1"
,
PHP_INI_SYSTEM
,
OnUpdateLongGEZero
,
WorkerId
,
zend_snowdrift_globals
,
snowdrift_globals
)
STD_PHP_INI_ENTRY
(
"snowdrift.WorkerIdNum"
,
"63"
,
PHP_INI_SYSTEM
,
OnUpdateLongGEZero
,
WorkerIdNum
,
zend_snowdrift_globals
,
snowdrift_globals
)
STD_PHP_INI_ENTRY
(
"snowdrift.WorkerIdBitLength"
,
"6"
,
PHP_INI_SYSTEM
,
OnUpdateLongGEZero
,
WorkerIdBitLength
,
zend_snowdrift_globals
,
snowdrift_globals
)
STD_PHP_INI_ENTRY
(
"snowdrift.SeqBitLength"
,
"6"
,
PHP_INI_SYSTEM
,
OnUpdateLongGEZero
,
SeqBitLength
,
zend_snowdrift_globals
,
snowdrift_globals
)
STD_PHP_INI_ENTRY
(
"snowdrift.MaxSeqNumber"
,
"0"
,
PHP_INI_SYSTEM
,
OnUpdateLongGEZero
,
MaxSeqNumber
,
zend_snowdrift_globals
,
snowdrift_globals
)
STD_PHP_INI_ENTRY
(
"snowdrift.MinSeqNumber"
,
"
0
"
,
PHP_INI_SYSTEM
,
OnUpdateLongGEZero
,
MinSeqNumber
,
zend_snowdrift_globals
,
snowdrift_globals
)
STD_PHP_INI_ENTRY
(
"snowdrift.MinSeqNumber"
,
"
5
"
,
PHP_INI_SYSTEM
,
OnUpdateLongGEZero
,
MinSeqNumber
,
zend_snowdrift_globals
,
snowdrift_globals
)
STD_PHP_INI_ENTRY
(
"snowdrift.TopOverCostCount"
,
"2000"
,
PHP_INI_SYSTEM
,
OnUpdateLongGEZero
,
TopOverCostCount
,
zend_snowdrift_globals
,
snowdrift_globals
)
PHP_INI_END
()
...
...
@@ -56,16 +55,12 @@ PHP_INI_END()
static
int
snowdrift_init
()
{
wid_num
=
(
-
1L
<<
SD_G
(
WorkerIdBitLength
))
^
-
1L
;
if
(
SD_G
(
WorkerIdNum
)
<
wid_num
)
{
wid_num
=
SD_G
(
WorkerIdNum
);
}
shmctx
.
size
=
wid_num
*
sizeof
(
snowflake
);
if
(
shm_alloc
(
&
shmctx
)
==
-
1
)
{
return
FAILURE
;
}
if
(
SD_G
(
MaxSeqNumber
)
<
SD_G
(
MinSeqNumber
))
if
(
SD_G
(
MaxSeqNumber
)
!=
0
&&
SD_G
(
MaxSeqNumber
)
<
SD_G
(
MinSeqNumber
))
{
return
FAILURE
;
}
...
...
PHP/src/snowflake/snowflake.c
浏览文件 @
2f3924ee
...
...
@@ -43,7 +43,10 @@ void Config(snowflake *flake)
flake
->
BaseTime
=
flake
->
BaseTime
!=
0
?
flake
->
BaseTime
:
1577808000000
;
flake
->
_TimestampShift
=
(
uint8_t
)(
flake
->
WorkerIdBitLength
+
flake
->
SeqBitLength
);
flake
->
_CurrentSeqNumber
=
flake
->
MinSeqNumber
;
return
;
if
(
flake
->
MaxSeqNumber
<=
flake
->
MinSeqNumber
)
{
flake
->
MinSeqNumber
=
0
;
}
}
void
inline
EndOverCostAction
(
uint64_t
useTimeTick
,
snowflake
*
flake
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录