mplanchard / cuid-rust

Rust implemention of CUID unique IDs
https://crates.io/crates/cuid
MIT License
90 stars 15 forks source link

Fix generated cuid length #2

Closed rasendubi closed 4 years ago

rasendubi commented 4 years ago

The currently generated cuids have variable length. Which makes this library incompatible with the original cuid library.

This library uses seconds resolution for generating timestamps which makes cuids more likely to collide and also increases the chance of counter rollover.

Counter is variable-length, which makes is non-monotonic when sorted in lexicographic order ("z" > "10" but 35 < 36).

Fix the issues above by using milliseconds resolution and padding counter to the block size.

rasendubi commented 4 years ago

Thanks for the merge and quick release!