https://github.com/rvhuang/snowflake-lite
A lightweight implementation of Twitter's Snowflake algorithm.
https://github.com/rvhuang/snowflake-lite
twitter-snowflake-algorithm
Last synced: 10 months ago
JSON representation
A lightweight implementation of Twitter's Snowflake algorithm.
- Host: GitHub
- URL: https://github.com/rvhuang/snowflake-lite
- Owner: rvhuang
- License: apache-2.0
- Created: 2016-02-05T04:48:02.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-02-05T13:03:12.000Z (over 10 years ago)
- Last Synced: 2023-03-03T00:23:28.439Z (over 3 years ago)
- Topics: twitter-snowflake-algorithm
- Language: C#
- Size: 13.7 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Snowflake-Lite .NET
### Overview
This is a lightweight implementation of [Twitter's Snowflake algorithm](https://github.com/twitter/snowflake/) on .NET platform. The library consists of only one class `IdFactory`, which is pretty much equal to [IdWorker](https://github.com/twitter/snowflake/blob/snowflake-2010/src/main/scala/com/twitter/service/snowflake/IdWorker.scala). However, there are still few main differences:
* When generating new ID, the `IdFactory` class employs spin lock instead of mutex to have faster performance.
* The default constructor of `IdFactory` class will extract local IP addresses as its worker ID and data center ID.
* Codes and exception messages are adjusted to follow [C# coding conventions](https://msdn.microsoft.com/en-us/library/ff926074.aspx).