1 stable release
1.0.0 | Sep 7, 2023 |
---|
#1311 in Database interfaces
7KB
85 lines
Sortable (timestamp-first) unique identifier
Why?
Random identifiers can be bad for performance when inserting into balanced b-tree indexes.
Variants
variant | timestamp bits | random bits |
---|---|---|
u32 , i32 |
16 (hours since unix epoch) | 16 |
u64 , i64 |
40 (seconds since unix epoch) | 24 |
u128 , i128 |
64 (milliseconds since unix epoch) | 64 |
License
lib.rs
:
Sortable (timestamp-first) unique identifier
Why?
Random identifiers can be bad for performance when inserting into balanced b-tree indexes.
Variants
variant | timestamp bits | random bits |
---|---|---|
u32 , i32 |
16 (hours since unix epoch) | 16 |
u64 , i64 |
40 (seconds since unix epoch) | 24 |
u128 , i128 |
64 (milliseconds since unix epoch) | 64 |
Usage
use suid::Suid;
println!("{}", u32::suid());
println!("{}", i32::suid());
println!("{}", u64::suid());
println!("{}", i64::suid());
println!("{}", u128::suid());
println!("{}", i128::suid());
License
Dependencies
~310KB