/ukey

PHP unique ID generator

Primary LanguageC

ukey

Based on the Twitter Snowflake algorithm

PHP unique ID generator

functions list:

    1. string ukey_next_id(void);
         Get the next unique ID.
    1. int ukey_to_timestamp(string ID);
         Change unique ID to timestamp.
    1. array ukey_to_machine(string ID);
         Change unique ID to machine info.

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