AtomPHP唯一ID生成扩展
使用Twitter的 Snowflake算法,有兴趣可以了解一下这个算法: https://github.com/twitter/snowflake
php.ini的配置项:
[ukey] ukey.datacenter = integer ukey.worker = integer ukey.twepoch = uint64
-
datacenter配置项是一个整数, 用于设置数据中心;
-
worker配置项是一个整数, 用于设置数据中心的机器序号;
-
twepoch配置项是一个64位的整数, 用于设置时间戳基数, 此值越大, 生成的ID越小;
Atom
Based on the Twitter Snowflake algorithm
PHP unique ID generator
functions list:
-
1) string atom_next_id(void);
Get the next unique ID. -
2) array atom_explain(string ID);
Change unique ID to array includes: timestamp, datacenter id and worker id.
example:
<?php $id = atom_next_id(); echo $id; $info = atom_explain($id); echo date('Y-m-d H:i:s', $info['timestamp']); ?>
install:
$ cd ./atom
$ phpize
$ ./configure
$ make
$ sudo make install
php.ini configure entries:
[atom]
atom.datacenter = integer
atom.worker = intger
atom.twepoch = uint64
评论
unidPHP的唯一ID生成
unid是一个可以生成唯一ID的php扩展,此扩展基于 TwitterSnowflake算法。有兴趣可以了解一下这个算法: https://github.com/twitter/snowflake
unidPHP的唯一ID生成
0
UKG唯一ID生成服务器
UKG(UniqueKeyGenerateServer)是一个唯一ID生成服务器,其根据Twitter的snowflake算法写成,性能非常高,稳定性非常好(在我们的服务器上跑了非常长的时间).而且协
UKG唯一ID生成服务器
0