ulid4s


License

License

Categories

Categories

Net
GroupId

GroupId

net.petitviolet
ArtifactId

ArtifactId

ulid4s_2.11
Last Version

Last Version

0.5.0
Release Date

Release Date

Type

Type

jar
Description

Description

ulid4s
ulid4s
Project URL

Project URL

https://github.com/petitviolet/ulid4s
Project Organization

Project Organization

net.petitviolet
Source Code Management

Source Code Management

https://github.com/petitviolet/ulid4s

Download ulid4s_2.11

How to add to project

<!-- https://jarcasting.com/artifacts/net.petitviolet/ulid4s_2.11/ -->
<dependency>
    <groupId>net.petitviolet</groupId>
    <artifactId>ulid4s_2.11</artifactId>
    <version>0.5.0</version>
</dependency>
// https://jarcasting.com/artifacts/net.petitviolet/ulid4s_2.11/
implementation 'net.petitviolet:ulid4s_2.11:0.5.0'
// https://jarcasting.com/artifacts/net.petitviolet/ulid4s_2.11/
implementation ("net.petitviolet:ulid4s_2.11:0.5.0")
'net.petitviolet:ulid4s_2.11:jar:0.5.0'
<dependency org="net.petitviolet" name="ulid4s_2.11" rev="0.5.0">
  <artifact name="ulid4s_2.11" type="jar" />
</dependency>
@Grapes(
@Grab(group='net.petitviolet', module='ulid4s_2.11', version='0.5.0')
)
libraryDependencies += "net.petitviolet" % "ulid4s_2.11" % "0.5.0"
[net.petitviolet/ulid4s_2.11 "0.5.0"]

Dependencies

compile (1)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.11.12

test (2)

Group / Artifact Type Version
org.scalatest : scalatest_2.11 jar 3.0.8
org.scalacheck : scalacheck_2.11 jar 1.14.0

Project Modules

There are no modules declared in this project.

ulid for Scala

MavenCentral Actions Status codecov

ULID (Universally Unique Lexicographically Sortable Identifier) generator and parser for Scala.

Refer ulid/spec.

Getting Started

libraryDependencies += "net.petitviolet" %% "ulid4s" % "<version>"

Example

scala> import net.petitviolet.ulid4s.ULID
import net.petitviolet.ulid4s.ULID

scala> ULID.generate
res0: String = 01CZX6XV0FQHFK33XA7X4QG4NK

scala> ULID.timeStamp(ULID.generate)
res1: Option[Long] = Some(1546094841642)

scala> System.currentTimeMillis
res2: Long = 1546094852651

Performance

JMH results are below.

$ git checkout v0.3.0 && sbt 'benchmark / jmh:run -i 3 -wi 3 -f 1 -t 1'
HEAD is now at 1770d2c fixed build.sbt

...

[info] Running (fork) org.openjdk.jmh.Main -i 3 -wi 3 -f 1 -t 1
[info] # JMH version: 1.21
[info] # VM version: JDK 1.8.0_192, Java HotSpot(TM) 64-Bit Server VM, 25.192-b12
[info] # VM invoker: /Library/Java/JavaVirtualMachines/jdk1.8.0_192.jdk/Contents/Home/jre/bin/java
[info] # VM options: <none>

...

[info] Benchmark                              Mode  Cnt       Score         Error  Units
[info] ULIDBench.generate_ULID_Random        thrpt    3  529616.492 ± 1496958.221  ops/s
[info] ULIDBench.generate_ULID_SecureRandom  thrpt    3   63538.492 ±    2606.774  ops/s
[info] ULIDBench.generate_UUID               thrpt    3  540198.296 ±  226327.267  ops/s

ULID provides a default ULID generator using SecureRandom, that is slower than UUID v4.
If you do not need strong randomeness on generating ULID, you can use other random generator e.g. Random instead of SecureRandom.

LICENSE

LICENSE

Versions

Version
0.5.0
0.4.1
0.4.0
0.3.0
0.2.0
0.1.0