unidPHP的唯一ID生成
unid是一个可以生成唯一ID的php扩展,此扩展基于 Twitter Snowflake 算法。有兴趣可以了解一下这个算法: https://github.com/twitter/snowflake
功能列表:
// 1) Get the next unique ID. string unid_next_id(void); // 2) Change unique ID to time stamp. int unid_get_time(string id); // 3) Change unique ID to worker id. array unid_get_worker_id(string id);
示例:
<?php $id = unid_next_id(); echo $id; $time = unid_get_time($id); echo 'date time is: ' . date('Y-m-d H:i:s', $time); $worker_id = unid_get_worker_id(); echo 'worker id is: ' . $worker_id; ?>
$ cd ./unid $ phpize $ ./configure $ make $ sudo make install
php.ini 配置项:
[unid] unid.datacenter = int unid.twepoch = uint64
评论
UKG唯一ID生成服务器
UKG(UniqueKeyGenerateServer)是一个唯一ID生成服务器,其根据Twitter的snowflake算法写成,性能非常高,稳定性非常好(在我们的服务器上跑了非常长的时间).而且协
UKG唯一ID生成服务器
0
AtomPHP唯一ID生成扩展
使用Twitter的 Snowflake算法,有兴趣可以了解一下这个算法: https://github.com/twitter/snowflake php.ini的配置项:[ukey]ukey.d
AtomPHP唯一ID生成扩展
0