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.
- 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.
To use this project, you need to have Zig version 0.14 installed. You can download it from the official Zig website.
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});
}
To run the code, use the following command:
zig build run
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
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.
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.
This project is licensed under the MIT License. See the LICENSE file for details.
Contributions are welcome! Please open an issue or submit a pull request on GitHub.
For any questions or suggestions, please contact the project maintainer.