Skip to content

Rivalz-ai/Superflake

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Superflake

Superflake is a revolutionary identification technology based on Twitter's Snowflake. A Superflake ID is generated by concatenating:

  • a 42-bit timestamp,
  • a 10-bit node ID, and
  • a 12-bit sequential number.

Features

  • Unique ID Generation: Generates unique IDs based on timestamp, node ID, and sequence number.
  • Custom Epoch: Allows setting a custom epoch for timestamp calculation.
  • High Performance: Written in Zig, a high-performance systems programming language.
  • Memory Safety: Ensures no memory leaks with Zig's safety features.
  • Simple and Efficient: Minimalistic and efficient implementation.

Installation

To use this project, you need to have Zig version 0.14 installed. You can download it from the official Zig website.

Usage

Here is an example of how to use the Superflake ID generator:

const std = @import("std");
const Superflake = @import("superflake");

pub fn main() !void {
    const superflake = Superflake.generate();
    const id_str = try superflake.toString();
    defer std.heap.page_allocator.free(id_str);

    std.debug.print("Generated Superflake ID: {s}\n", .{id_str});
}

Running the Code

To run the code, use the following command:

zig build run

Testing

The project includes tests to ensure the correct functionality of the Superflake ID generator. To run the tests, use the following command:

zig build test

Performance

Superflake is designed to be highly performant, leveraging Zig's low-level capabilities and safety features. The implementation ensures efficient memory usage and avoids memory leaks, making it suitable for high-performance applications.

Memory Safety

Zig's safety features, such as compile-time checks and explicit memory management, help ensure that the Superflake implementation is free from memory leaks and other common memory-related issues.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contributing

Contributions are welcome! Please open an issue or submit a pull request on GitHub.

Contact

For any questions or suggestions, please contact the project maintainer.

About

Superflake Zig lang ID generator

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages