FWDekker / intellij-randomness

IntelliJ plugin for inserting random numbers, UUIDs, names, IP addresses, and much more
https://plugins.jetbrains.com/plugin/9836-randomness
MIT License
45 stars 7 forks source link

TSID generator #540

Open originalrusyn opened 1 month ago

originalrusyn commented 1 month ago

Problem Currently, there is no built-in mechanism for generating unique identifiers that are both time-sorted and globally unique. This lack of functionality complicates the efficient organization and querying of records in time-based sequences. For instance, in scenarios where logs or events need to be sorted chronologically, having an identifier that reflects the timestamp of creation would simplify data management and improve performance. Additionally, users need the ability to select the format of the identifier, either as a long or a String, depending on their specific use case.

Suggested solution Implement a feature to generate Time-Sorted Unique Identifiers (TSID) with the following capabilities based on https://github.com/vladmihalcea/hypersistence-tsid

FWDekker commented 1 month ago

Interesting! I hadn't heard of TSIDs before. If I want to prevent cluttering the menu with too many options, do you think that adding TSID as a variant of UUID would make sense? So, in the UUID menu, you'd have the dropdown "Version" with values 1, 4, 6, 8, and TSID. If not, do you have alternative suggestions?

originalrusyn commented 1 month ago

If I want to prevent cluttering the menu with too many options, do you think that adding TSID as a variant of UUID would make sense? So, in the UUID menu, you'd have the dropdown "Version" with values 1, 4, 6, 8, and TSID. If not, do you have alternative suggestions?

Well, I'm okay with it, but I think TSID isn't the same as UUID (for example, TSID uses 64 bits while UUID uses 128 bits). Therefore, it might be better to consider renaming the "UUID" menu item to something like "Distributed UID", "Unique ID", or "Unique Key", or to introduce a new menu item altogether.

FWDekker commented 1 month ago

Good point! I'll think about how I can categorise it neatly. I don't have a lot of time right now, but might later this month.