Snowflake53 1.0.1
dotnet add package Snowflake53 --version 1.0.1
NuGet\Install-Package Snowflake53 -Version 1.0.1
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="Snowflake53" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Snowflake53" Version="1.0.1" />
<PackageReference Include="Snowflake53" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Snowflake53 --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Snowflake53, 1.0.1"
#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.
#:package Snowflake53@1.0.1
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Snowflake53&version=1.0.1
#tool nuget:?package=Snowflake53&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Snowflake53
Twitter Snowflake-alike ID generator 53bit for .NetCore 3.0. Available as Nuget package
说明
Twitter's Snowflake 是一个ID自动生成的方法,可以用于生成数据库的主键。但是它生成的是64位的整数,在浏览器前端无法处理。Snowflake53生成53位长度的整数。
如何工作
Snowflake53由以下三部分合并组成:
- Timestamp
- Generator-id
- Sequence
Timestamp是41位的时间戳,从2019年7月1日开始。 Generator-id是2位的生成器编号,从0到3,只有4个生成器,最多只能用于4台主机同时生成序列号。 Sequence是10位长度的序列号。
开始使用
从Nuget package安装并编写以下程序:
using Snowflake53;
using System;
class Program
{
static void Main(string[] args)
{
var generator = new IdGenerator(0);
Console.WriteLine(generator.CreateId());
}
}
输出:
9410778017792
本程序在mac机器dotnet core 3.0环境下简单测试通过。MIT协议发布。
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
.NET Core | netcoreapp3.0 is compatible. netcoreapp3.1 was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETCoreApp 3.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.