php 添加snowflake扩展

雪花ID全家桶 https://gitee.com/yitter/idgenerator

php扩展安装 https://gitee.com/yitter/idgenerator/tree/master/PHP

git clone https://gitee.com/yitter/idgenerator.git
cd idgenerator/PHP
phpize

./configure --with-php-config=/path/php-config
//修改path地址
//./configure --with-php-config=/usr/bin/php-config

make
make install

新建文件snowdrift.ini,上传到 /etc/php/7.4/mods-available

extension=snowdrift.so
snowdrift.Method=1 // 雪花计算方法,(1-漂移算法|2-传统算法),默认1
snowdrift.BaseTime=1620442145000 //基础时间(ms单位),不能超过当前系统时间
snowdrift.WorkerId=1 //机器码,必须由外部设定,最大值 2^WorkerIdBitLength-1
snowdrift.WorkerIdBitLength=6 //机器码位长,默认值6,取值范围 [1, 15](要求:序列数位长+机器码位长不超过22)
snowdrift.SeqBitLength=6 //序列数位长,默认值6,取值范围 [3, 21](要求:序列数位长+机器码位长不超过22)
snowdrift.MaxSeqNumber=0 //最大序列数(含),设置范围 [MinSeqNumber, 2^SeqBitLength-1],默认值0,表示最大序列数取最大值(2^SeqBitLength-1]
snowdrift.MinSeqNumber=5 //最小序列数(含),默认值5,取值范围 [5, MaxSeqNumber],每毫秒的前5个序列数对应编号0-4是保留位,其中1-4是时间回拨相应预留位,0是手工新值预留位
snowdrift.TopOverCostCount=2000 //最大漂移次数(含),默认2000,推荐范围 500-20000(与计算能力有关)

 

phpenmod snowdrift

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值