f4b6a3/uuid-creator

Fast version of UUID v7

marcotama opened this issue · 3 comments

Hello!

This is a feature request.

Could you add a fast (i.e. non-cryptographic) version of UUID v7, same as you have for v4?

Hi @marcotama !

I like the idea, but I don't plan on adding more features soon.

However, you can do the following.

Use GUID alternative:

UUID uuid = GUID.v7().toUUID();

Or use the v7 factory directly:

TimeOrderedEpochFactory v7 = TimeOrderedEpochFactory.builder().withFastRandom().build(); // for reuse
UUID uuid = v7.create();

The first option is extremely fast because it is very simple as you can see in the source code.

The second option is a faster version of UuidCreator.getTimeOrderedEpoch(), that is, with the same implementation, except for the random generator.

Hi @fabiolimace , thank you for the reply! I did not know about this API, that's perfect for my needs. It might be worth adding it to the README, maybe? Regardless, thank you for making this library!

I just updated the README to better explain the new GUID API.

I won't mention TimeOrderedEpochFactory because there are already some examples on the Wiki pages.

P.S. I'm very happy that this project can be useful.