diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3d27b67..f6288c8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,10 @@ All notable changes to this project will be documented in this file.
Nothing unreleased.
+## [5.1.0] - 2022-10-22
+
+Add a fast method to generate identifiers. #22
+
## [5.0.2] - 2022-09-17
Rewrite docs. #21
@@ -298,8 +302,9 @@ Project created as an alternative Java implementation of [ULID spec](https://git
- Added `LICENSE`
- Added test cases
-[unreleased]: https://github.com/f4b6a3/ulid-creator/compare/ulid-creator-5.0.2...HEAD
-[5.0.2]: https://github.com/f4b6a3/ulid-creator/compare/ulid-creator-5.0.0...ulid-creator-5.0.2
+[unreleased]: https://github.com/f4b6a3/ulid-creator/compare/ulid-creator-5.1.0...HEAD
+[5.0.2]: https://github.com/f4b6a3/ulid-creator/compare/ulid-creator-5.0.2...ulid-creator-5.1.0
+[5.0.2]: https://github.com/f4b6a3/ulid-creator/compare/ulid-creator-5.0.1...ulid-creator-5.0.2
[5.0.1]: https://github.com/f4b6a3/ulid-creator/compare/ulid-creator-5.0.0...ulid-creator-5.0.1
[5.0.0]: https://github.com/f4b6a3/ulid-creator/compare/ulid-creator-4.2.1...ulid-creator-5.0.0
[4.2.1]: https://github.com/f4b6a3/ulid-creator/compare/ulid-creator-4.2.0...ulid-creator-4.2.1
diff --git a/README.md b/README.md
index 9a187ec..e45b87e 100644
--- a/README.md
+++ b/README.md
@@ -43,7 +43,7 @@ Add these lines to your `pom.xml`.
- * ULID is 128-bit value that has two components: + * ULID is a 128-bit value that has two components: *
+ * This static method is a quick alternative to {@link UlidCreator#getUlid()}. + *
+ * It employs {@link SplittableRandom} which works very well, although not + * cryptographically strong. + *
+ * Security-sensitive applications that require a cryptographically secure
+ * pseudo-random generator should use {@link UlidCreator#getUlid()}.
+ *
+ * @return a ULID
+ * @see {@link SplittableRandom}
+ * @since 5.1.0
+ */
+ public static Ulid fast() {
+ final long time = System.currentTimeMillis();
+ final SplittableRandom random = new SplittableRandom();
+ return new Ulid((time << 16) | (random.nextLong() & 0xffffL), random.nextLong());
+ }
+
/**
* Converts a UUID into a ULID.
*
@@ -677,7 +699,7 @@ public final class Ulid implements Serializable, Comparable
* The first of two ULIDs is greater than the second if the most significant
- * byte in which they differ is greater for the first UUID.
+ * byte in which they differ is greater for the first ULID.
*
* @param that a ULID to be compared with
* @return -1, 0 or 1 as {@code this} is less than, equal to, or greater than
diff --git a/src/test/java/com/github/f4b6a3/ulid/UlidTest.java b/src/test/java/com/github/f4b6a3/ulid/UlidTest.java
index 109ae71..4a85e0f 100644
--- a/src/test/java/com/github/f4b6a3/ulid/UlidTest.java
+++ b/src/test/java/com/github/f4b6a3/ulid/UlidTest.java
@@ -15,7 +15,7 @@ import java.util.UUID;
import org.junit.Test;
-public class UlidTest {
+public class UlidTest extends UlidFactoryTest {
private static final int DEFAULT_LOOP_MAX = 1_000;
@@ -577,6 +577,23 @@ public class UlidTest {
}
}
+ @Test
+ public void testUlidFast() {
+ Ulid[] list = new Ulid[DEFAULT_LOOP_MAX];
+
+ long startTime = System.currentTimeMillis();
+
+ for (int i = 0; i < DEFAULT_LOOP_MAX; i++) {
+ list[i] = Ulid.fast();
+ }
+
+ long endTime = System.currentTimeMillis();
+
+ checkNullOrInvalid(list);
+ checkUniqueness(list);
+ checkCreationTime(list, startTime, endTime);
+ }
+
public static Ulid fromString(String string) {
long time = 0;