Skip to content

Sha10FF/uuid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

UUID

Simple TimeUUID and UUID library for distributed architecture.

MicroUuid

Simple 96bit timeuuid realization that close to in-build PHP timestamp with microseconds. Time precision will not be lost. Correctly sortable by time unlike UUID1(time uuid) However you can't use MicroUuid for historical dates like UUID. So use this within range: 1970-01-01 - 2106-02-07. MicroUuid if fully compatible with 32bit architecture (Intel Atom, Celeron, RaspberryPi etc). Y2038 problem will not affect MicroUuid as well.

Why this so unique: every server and worker of fasts-cgi process has unique SEVER_ID and pid; For the collision in only process should be generated more than 64 MicroUuid within single microsecond. This is not possible even in a cycle without any other logic even if you overclock CPU up to 12Ghz.

It looks like hex string: 5e021ada-a5956-080127f-1cc6 (27 chars), where

  • first part is unix timestamp in seconds
  • second part is microseconds
  • third is sequence and pid (unix process id)
  • and last is server id

or : XgIkWjPAYEAaHQAA - base64 encoded binary (16 chars)

It need only BINARY(12) column to store, correctly sortable (by time with micros) (hex string and base64 presentation are correctly sortable as well)

ServerId

If you use multiple servers it is highly recommended to add unique SERVER_ID=[0-65535] in /etc/environment (You could also find useful to add SERVER_ROLE=[PROD|TEST|DEV] as well) Or just add in config: MicroUuid::$defaultServer = 12345;

Alternative methods will be used for generating machine dependent server id if you not set it directly.

Uuid

Simple and correct RFC4122 uuid. Works with any possible variant and 32bit save unlike other popular libs.

About

Simple TimeUUID and UUID library for distributed architecture. 32bit cpu compatible.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages