2017 © Pedro Peláez
 

library particle

image

sschiau/particle

  • Wednesday, April 4, 2018
  • by sschiau
  • Repository
  • 7 Watchers
  • 93 Stars
  • 108 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 22 Forks
  • 0 Open issues
  • 9 Versions
  • 50 % Grown

The README.md

Build Status Latest Stable Version License, (*1)

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., (*2)

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., (*3)

How to use it

Generate Particle ID

Change const EPOCH in particle class to today epoch time w/ millisecond (13 digits), (*4)

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

Time from Particle ID (w/ millisecond precision)

    $particleID = '4611692470816737853';
    Particle::timeFromParticle($particleID);

The Versions

04/04 2018

v1.0.1

1.0.1.0

  Sources   Download

24/02 2018

dev-master

9999999-dev

  Sources   Download

MIT LICENSE.md

The Requires

  • php ^7.1.7

 

The Development Requires

20/10 2017

2.2.2

2.2.2.0

  Sources   Download

LICENSE.md

The Requires

  • php ^7.1.7

 

The Development Requires

27/08 2017

2.2.1

2.2.1.0

  Sources   Download

LICENSE.md

The Requires

  • php ^7.1.7

 

The Development Requires

24/12 2016

2.2.0

2.2.0.0

  Sources   Download

LICENSE.md

The Requires

  • php ^5.5.3 || ^7.0

 

The Development Requires

06/12 2016

2.1.0

2.1.0.0

  Sources   Download

LICENSE.md

The Requires

  • php ^5.5.3 || ^7.0

 

The Development Requires

19/11 2016

2.0.0

2.0.0.0

  Sources   Download

LICENSE.md

The Requires

  • php ^5.5.3 || ^7.0

 

17/08 2016

1.1.2

1.1.2.0

  Sources   Download

LICENSE.md

The Requires

  • php ^5.5.3 || ^7.0

 

16/08 2016

1.0.2

1.0.2.0

  Sources   Download