SnowflakeIdGeneratorForCsharp 7.0.0
dotnet add package SnowflakeIdGeneratorForCsharp --version 7.0.0
NuGet\Install-Package SnowflakeIdGeneratorForCsharp -Version 7.0.0
<PackageReference Include="SnowflakeIdGeneratorForCsharp" Version="7.0.0" />
paket add SnowflakeIdGeneratorForCsharp --version 7.0.0
#r "nuget: SnowflakeIdGeneratorForCsharp, 7.0.0"
// Install SnowflakeIdGeneratorForCsharp as a Cake Addin
#addin nuget:?package=SnowflakeIdGeneratorForCsharp&version=7.0.0
// Install SnowflakeIdGeneratorForCsharp as a Cake Tool
#tool nuget:?package=SnowflakeIdGeneratorForCsharp&version=7.0.0
Snowflake ID Generator for C#
Overview
This library provides a simple and thread-safe Snowflake ID generator for C#. Snowflake IDs are unique, distributed, time-sortable identifiers. This is particularly useful for distributed systems where you cannot guarantee uniqueness of IDs generated independently at multiple locations.
Features
* Thread-safe: Generate IDS concurently without conflicts.
* Customizable: Set custom worket and data center IDs.
* Time-sortable: IDs can be sorted by the time of teir generation.
Installation
You can download the package from NuGet:
Install-package SnowflakeIdGeneratorForCsharp
Or add it directly to your project file:
<PackageReference Include="SnowflakeIdGeneratorForCsharp" Version="x.x.x" />
Usage
var idGenerator = new SnowflakeIdGenerator(1, 1);
long uniqueId = idGenerator.CreateId();
Configuration
You can customize worker and data center IDs during the initialization of the SnowflakeIdGenerator
:
var idGenerator1 = new SnowflakeIdGenerator(1, 1); // for the first server
var idGenerator2 = new SnowflakeIdGenerator(2, 1); // for the second server
var idGenerator3 = new SnowflakeIdGenerator(1, 2); // for a server in a different data center
Contributing
If you find any issues or have suggestions for improvements, please create an issue or a pull request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net7.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
7.0.0 | 160 | 9/15/2023 |