A global Id generator for Kotlin Multiplatform. It modifies the timestamp to 5 bytes based on Xid.
Warning: Currently not compatible with Xid.
Name | Binary Size | String Size | Time Limit | Features |
---|---|---|---|---|
UUID | 16 bytes | 36 chars | / | configuration free, not sortable |
shortuuid | 16 bytes | 22 chars | / | configuration free, not sortable |
Snowflake | 8 bytes | up to 20 chars | 69 years | needs machine/DC configuration, needs central server, sortable |
MongoID | 12 bytes | 24 chars | 136 years | configuration free, sortable |
Xid | 12 bytes | 20 chars | 136 years | configuration free, sortable |
Diglol Id | 13 bytes | 21 chars | 34865 years | configuration free, sortable |
implementation("com.diglol.id:id:0.3.0")
val id = Id.generate()
println(id)
// 输出: 016ohoarc3q8dp1884msi
Get id
embedded info:
id.machine
id.pid
id.time
id.counter
Copyright 2022 Diglol
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.