| Crates.io | leaves |
| lib.rs | leaves |
| version | 0.5.0 |
| created_at | 2019-11-24 16:34:42.467338+00 |
| updated_at | 2020-08-20 09:07:46.257279+00 |
| description | Distributed ID Allocator |
| homepage | |
| repository | https://github.com/songzhi/leaves |
| max_upload_size | |
| id | 184004 |
| size | 112,219 |
This is a unofficial port of Leaf.
🏠 Homepage
Enabling the mysql and runtime-tokio feature:
use leaves::dao::MySqlLeafDao;
use leaves::{SegmentIDGen, Config, Result};
#[tokio::main]
async main() -> Result<()> {
let dao = Arc::new(MySqlLeafDao::new("mysql://...").await?);
let mut service = SegmentIDGen::new(dao, Config::new());
service.init().await?;
let tag = 1;
for _ in 0..1000 {
println!("{}", service.get(tag).await?);
}
}
1,000,000 IDs in 180ms(local MongoDB with R7 3700X)