sschiau/particle
Composer 安装命令:
composer require sschiau/particle
包简介
README 文档
README
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 v8.4.14)
- 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/ millisecond (13 digits)
$machineID = 0; // Machine ID (aka Server ID no.) Particle::generateParticle($machineID);
Time from Particle ID (w/ millisecond precision)
$particleID = '4611691166465789880'; Particle::timeFromParticle($particleID);
统计信息
- 总下载量: 3.92k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 135
- 点击次数: 2
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-08-17