PHP的唯一ID生成 unid

码农软件 · 软件分类 · 常用工具包 · 2019-08-14 14:27:31

软件介绍

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

本文地址:https://www.codercto.com/soft/d/12350.html

Rework

Rework

Jason Fried、David Heinemeier Hansson / Crown Business / 2010-3-9 / USD 22.00

"Jason Fried and David Hansson follow their own advice in REWORK, laying bare the surprising philosophies at the core of 37signals' success and inspiring us to put them into practice. There's no jarg......一起来看看 《Rework》 这本书的介绍吧!

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试