SnowFlakeID Delphi
1.0.0
Snowflake's unique identifier generation system is a method of generating unique identifiers for objects within a distributed system or database.

In distributed systems, generating unique identifiers is crucial for tracking and managing entities across multiple machines. Using a snowflake ID approach ensures that IDs are system unique rather than globally unique, minimizing conflicts in high-volume environments, AND it's sortable.
This design fits within a 64-bit integer (Int64).
Several companies have adopted Snowflake IDs for efficient ID generation:
SFID.pas unit to your Delphi project.TSFID, create new ID TSFID.NewSfid.uses
SFID;
var
Sfid: TSFID;
begin
// Create a new Snowflake ID with the current timestamp, default machine ID, and a new sequence
Sfid := TSFID.NewSfid;
// Get Unique ID as int64 base
WriteLn('Snowflake ID as Integer: ', Sfid.AsInt);
// Access components of the Snowflake ID
WriteLn('Timestamp: ', Sfid.Timestamp);
WriteLn('Machine ID: ', Sfid.MachineID);
WriteLn('Sequence: ', Sfid.Sequence);
end;Shadi Ajam
YES! We’d love your support! Please give it a ? and share it with others.
Share on social media: