Question: How to generate uuid (v4) without the hyphens in most performant way?
See original GitHub issueI have a use-case where I need UUIDs in high volume with no hyphens in them. I understand that we can do uuid().replace(/-/g, '')
. But is that performant enough? The process of replacing after generation also seems wasteful.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:4
- Comments:5 (3 by maintainers)
Top Results From Across the Web
random - Efficient method to generate UUID String in Java ...
This does it: public static void main(String[] args) { final String uuid = UUID.randomUUID().toString().replace("-" ...
Read more >You Might Not Need UUID V4 for Generating Random Identifiers
For many applications you might need to generate some kind of unique identifier to be able to get a reference to specific content....
Read more >Java UUID - Javatpoint
The randomUUID() method randomly generate the UUID. Whenever we run the program, it generates a new UUID. The signature of the method is:...
Read more >What is a UUID, and why should you care? - Cockroach Labs
They can be generated without the need to check against a central node, so in a distributed system, each node can generate UUIDs...
Read more >Universally unique identifier - Wikipedia
When generated according to the standard methods, UUIDs are, for practical purposes, unique. Their uniqueness does not depend on a central registration ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@OctaneInteractive et al:
uuidv4()
should return a string, so thetoString()
is probably not necessary.FWIW,
replaceAll()
is now a thing and probably slightly more performant thanreplace()
. (Note: Requires node 15+)@mateja176 Mongo DB querying? As noted above, the perf of
replace()
is almost certainly dwarfed by whatever Mongo is doing to process the query.