ukey
Based on the Twitter Snowflake algorithm
PHP unique ID generator
functions list:
-
- string ukey_next_id(void);
Get the next unique ID.
- string ukey_next_id(void);
-
- int ukey_to_timestamp(string ID);
Change unique ID to timestamp.
- int ukey_to_timestamp(string ID);
-
- array ukey_to_machine(string ID);
Change unique ID to machine info.
- array ukey_to_machine(string ID);
example:
<?php $id = ukey_next_id(); echo $id;
$timestamp = ukey_to_timestamp($id); echo date('Y-m-d H:i:s', $timestamp); ?>
install:
$ cd ./ukey
$ phpize
$ ./configure
$ make
$ sudo make install
php.ini configure entries:
[ukey]
ukey.worker = integer
ukey.datacenter = integer
ukey.twepoch = uint64