liexusong / atom

PHP unique ID generator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Atom

PHP unique ID generator, based on the Twitter snowflake algorithm

APIs:

/*
 * Get the next unique ID
 */
string atom_next_id()

/*
 * Change unique ID to array includes: timestamp, datacenter id and worker id
 */
array atom_explain(string $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 = integer
atom.twepoch = uint64

About

PHP unique ID generator


Languages

Language:C 82.0%Language:M4 10.8%Language:PHP 5.6%Language:JavaScript 1.5%