Skip to content

A .NET Standard 2.0 port of Segment’s K-Sortable Unique IDentifiers(KSUID) library.

License

Notifications You must be signed in to change notification settings

viveks7/DotKsuid

Repository files navigation

DotKsuid

A .NET Standard 2.0 port of Segment's implementation of K-Sortable Unique IDentifiers(KSUID). You can use this instead of GUID's where you can take advantage of it's

  • Natural ordering by generation time
  • Collision-free, coordination-free & dependency-free nature
  • Highly portable representation

Build Quality Gate Status Coverage

Installation

To install from NuGet with dotnet CLI, use following command

dotnet add package DotKsuid --version 1.0.0

Usage

To create a new KSUID

var ksuid = Ksuid.NewKsuid();

To convert a KSUID to it's base62 encoded string representation

var ksuidString = Ksuid.NewKsuid().ToString();

Performance

While this can't achieve the same performance as framework supported GUID's (since they are generated by calling native OS methods), it is written to be as fast as possible. Below is a benchmark result from the included Benchmarks project aganist GUID's

Screenshot 2021-06-18 at 10.14.40 PMScreenshot 2021-06-18 at 10 14 40 PM

Below is a benchmark aganist the only other port of KSUID's available currently for .NET (tagged as "Ksuids" & "KsuidString").

Screenshot 2021-06-18 at 10.22.04 PMScreenshot 2021-06-18 at 10 22 04 PM

As you can see this solution has a vastly improved performance compared to other existing implementations.

About

A .NET Standard 2.0 port of Segment’s K-Sortable Unique IDentifiers(KSUID) library.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages