SnowflakeIdGeneratorForCsharp 8.0.0

dotnet add package SnowflakeIdGeneratorForCsharp --version 8.0.0
NuGet\Install-Package SnowflakeIdGeneratorForCsharp -Version 8.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SnowflakeIdGeneratorForCsharp" Version="8.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SnowflakeIdGeneratorForCsharp --version 8.0.0
#r "nuget: SnowflakeIdGeneratorForCsharp, 8.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install SnowflakeIdGeneratorForCsharp as a Cake Addin
#addin nuget:?package=SnowflakeIdGeneratorForCsharp&version=8.0.0

// Install SnowflakeIdGeneratorForCsharp as a Cake Tool
#tool nuget:?package=SnowflakeIdGeneratorForCsharp&version=8.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 Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.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
8.0.0 193 11/15/2023
7.0.0 145 9/15/2023