Giter Club home page Giter Club logo

ebean-uuidv7's Introduction

ebean-uuidv7

A Version 7 UUID generator

Refer: https://www.ietf.org/archive/id/draft-peabody-dispatch-new-uuid-format-04.html#v7

This is a derived work of the UUID v7 generator from https://github.com/cowtowncoder/java-uuid-generator . This implementation removes the support for monotonic ordering (see cowtowncoder/java-uuid-generator#69) removing the associated lock and state associated with that (making this implementation stateless and lock free).

That is, UUID v7 only requires the first 48 bits to be continually increasing, just like the ULID specification.

Some implementations use an optional counter to provide additional monotonicity for identifiers created by the same generator but monotonicity is not required. As such this implementation prefers not to support monotonicity and thus provide a stateless and lock free V7 implementation.

Using defaults for Clock and Random provider

UUID uuid = UUIDv7.generate();

Using Builder to specify Clock and Random provider

Clock mySillyClock = Clock.fixed(Instant.EPOCH, ZoneId.of("UTC"));
Random myRandom = SecureRandom.getInstanceStrong();

UUIDv7 uuidV7 = UUIDv7.builder()
        .clock(mySillyClock)
        .random(myRandom)
        .build();

UUID uuid = uuidV7.next();

Examples

018e0dd3-0b7f-707c-925f-fa706a66e90a
018e0dd3-0b7f-77ef-b588-eeea489712ec
018e0dd3-0b7f-76a5-8221-3a8efe40ab3f
018e0dd3-0b7f-7817-b455-500a669b5bfb
018e0dd3-0b7f-7018-9082-c5aeb131cdbe
018e0dd3-0b7f-7d70-9ba5-08f2d5ca66b0
018e0dd3-0b7f-7abc-8f19-247dae93c98a
018e0dd3-0b7f-7ade-b287-64c5f7dff1e4
018e0dd3-0b7f-7448-a77c-94cfc26f63a3
018e0dd3-0b7f-7b5a-a6d4-be23fe1a1d7b

Maven dependency

<dependency>
  <groupId>io.ebean</groupId>
  <artifactId>ebean-uuidv7</artifactId>
  <version>0.1</version>
</dependency>

ebean-uuidv7's People

Contributors

rbygrave avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.