Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Snowflake's unique identifier generation system for objects within a distributed system or database.

License

NotificationsYou must be signed in to change notification settings

shadiajam/SnowFlakeID-Delphi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Snowflake IDs for Delphi

Why you need it!?

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, ANDit's sortable.

Snowflake Components Usage

  • Timestamp: Represents the time when the ID was generated, facilitating chronological ordering.
  • MachineID: Serves as a sender ID, identifying the specific machine or instance that generated the ID, ensuring system uniqueness.
  • Sequence: Functions as an acknowledgment counter, incrementing with each ID generated, allowing multiple IDs to be created without collision.

This design fits within a 64-bit integer(Int64).

Companies Using Snowflake IDs

Several companies have adopted Snowflake IDs for efficient ID generation:

  • Twitter: Utilized Snowflake IDs for unique identifiers in their tweet and user systems, enabling scalability and efficient data indexing.
  • Instagram: Employed Snowflake IDs for photos and user accounts, ensuring unique content identification and efficient database operations.
  • Uber: Implemented Snowflake IDs for trips and drivers, supporting global scalability and efficient data tracking across their systems.
  • Airbnb: Used Snowflake IDs for listings and bookings, achieving global uniqueness and reliable inventory management.
  • GitHub: Leveraged Snowflake IDs for repositories and issues, ensuring unique identification and smooth navigation for developers.

Usage

  1. Clone or simply download the unit: Clone the repository or download theSFID.pas unit to your Delphi project.
  2. Start using it: Assign new variable fromTSFID, create new IDTSFID.NewSfid.
  3. Please give it a 🌟 and share it with others

Examples

Example: Simple generate SnowFlake ID

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;

Author

  • Shadi Ajam

    GitHubLinkedIn

Useful Unit, Right?

YES! We’d love your support! Please give it a 🌟 and share it with others.

Share on social media:

Share on LinkedInShare on Dev.toShare on XShare on RedditShare on Facebook

About

Snowflake's unique identifier generation system for objects within a distributed system or database.

Topics

Resources

License

Stars

Watchers

Forks

Languages


[8]ページ先頭

©2009-2025 Movatter.jp