Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/diglol/id
Diglol Id is a global Id generator for Kotlin Multiplatform.
https://github.com/diglol/id
global-id id id-generator kotlin multiplatform unique-id
Last synced: 3 months ago
JSON representation
Diglol Id is a global Id generator for Kotlin Multiplatform.
- Host: GitHub
- URL: https://github.com/diglol/id
- Owner: diglol
- License: apache-2.0
- Created: 2021-05-29T06:16:16.000Z (over 3 years ago)
- Default Branch: trunk
- Last Pushed: 2024-06-11T11:50:16.000Z (5 months ago)
- Last Synced: 2024-07-12T21:14:46.645Z (4 months ago)
- Topics: global-id, id, id-generator, kotlin, multiplatform, unique-id
- Language: Kotlin
- Homepage:
- Size: 698 KB
- Stars: 10
- Watchers: 1
- Forks: 1
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- kmp-awesome - Diglol Id - A global Id generator for Kotlin Multiplatform. (Libraries / 🔧 Utils)
README
# Diglol Id
A global Id generator for Kotlin Multiplatform. It modifies the timestamp to 5 bytes based on [Xid].
> **Warning**: Currently not compatible with [Xid].
### Compare common global Id generators
| 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 |### Add Dependency
```gradle
implementation("com.diglol.id:id:0.3.0")
```### Code Samples
```kotlin
val id = Id.generate()
println(id)
// 输出: 016ohoarc3q8dp1884msi
```Get `id` embedded info:
```kotlin
id.machine
id.pid
id.time
id.counter
```### License
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 athttp://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.[UUID]: https://en.wikipedia.org/wiki/Universally_unique_identifier
[shortuuid]: https://github.com/stochastic-technologies/shortuuid
[Snowflake]: https://blog.twitter.com/2010/announcing-snowflake
[MongoID]: https://docs.mongodb.org/manual/reference/object-id/
[Xid]: https://github.com/rs/xid