Skip to content
64 bit ID Generator
Branch: master
Clone or download
Latest commit 2a0b209 Sep 27, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github/ISSUE_TEMPLATE Update issue templates Sep 27, 2018
Demo Bump version to 2.2.2 Oct 20, 2017
Sources Bump version to 2.2.2 Oct 20, 2017
Tests Bump version to 2.2.2 Oct 20, 2017
.gitignore
.travis.yml Update Travis PHP version for testing to 7.1.7 Aug 27, 2017
CHANGELOG.md Bump version to 2.2.2 Oct 20, 2017
CODE_OF_CONDUCT.md Create CODE_OF_CONDUCT.md Aug 26, 2017
CONTRIBUTING.md Create CONTRIBUTING.md Aug 26, 2017
LICENSE.md Changed license from Apache 2.0 to MIT License Oct 20, 2017
README.md
composer.json Change to valid SPDX license identifier Feb 24, 2018
composer.lock Auto bump versions Aug 27, 2017

README.md

Build Status Latest Stable Version License

Particle

Language: PHP

64bits int Time Based ID Generator

Uncoordinated

For high availability within and across data centers, machines generating ids should not have to coordinate with each other.

Solution

  • PHP (tested on v7.1.8)
  • Particle Id (64 bits) is composed of:
    • time - 42 bits (millisecond precision w/ a custom epoch)
    • configured machine id - 10 bits - up to 1024 machines
    • sequence number - 12 bits - up to 4096 random numbers

System Clock Dependency

You should use NTP to keep your system clock accurate.

How to use it

Generate Particle ID

Change const EPOCH in particle class to today epoch time w/ miliseconds (13 digits)

	$machineID = 0; // Machine ID (aka Server ID no.)
	Particle::generateParticle($machineID);

Time from Particle ID (w/ milisecond precision)

	$particleID = '4611692470816737853';
	Particle::timeFromParticle($particleID);
You can’t perform that action at this time.