Download the PHP package ada-u/chocoflake without Composer
On this page you can find all versions of the php package ada-u/chocoflake. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ada-u/chocoflake
More information about ada-u/chocoflake
Files in ada-u/chocoflake
Package chocoflake
Short Description 64bit time based id generator
License MIT
Homepage https://github.com/ada-u/chocoflake
Informations about the package chocoflake
chocoflake
64bit ID Generator for PHP
chocoflake
is an implementation of twitter Snowflake concept. This provides generating IDs based on time in a distributed environment.
Usage
Prerequisites
- PHP 8.0 or later
Installation
Command
composer.json
Sample
Configuration
- 41 bit - for timestamp
- 5 bit - for region id
- 5 bit - for server id
- 12 bit - for sequence per milliseconds
- 1414334507356 - service start epoch (unix timestamp)
ID Generator
I implemented two ID generators, Redis and SharedMemory version.
SharedMemory version
Using shared memory and semaphore (as mutex) to prevent multiple processes are in the critical section at the same time.
Redis version
Using Redis atomic increment operation to count up sequence.
ID Specification
The IDs consist of four elements:
- timestamp
- region id
- server id
- sequence
You can specify any bit length to each element.
Test
License
This software is released under the MIT License, see LICENSE
All versions of chocoflake with dependencies
mockery/mockery Version 1.4.*
predis/predis Version 1.1.*
ext-sysvsem Version *
ext-sysvshm Version *