KandraUuid

object KandraUuid

Generates UUID values for use as primary/clustering key columns.

Cassandra/ScyllaDB writes are upserts on partition key + clustering key — there is no separate insert-vs-overwrite path. Keys derived from Instant.now() collide silently if two rows land in the same millisecond. timeOrdered avoids that by using UUIDv7, whose 48-bit millisecond timestamp sits in the leading bytes of the value, so plain lexicographic comparison — exactly how Cassandra's UUIDType comparator orders a generic uuid column — already sorts chronologically. No dedicated timeuuid CQL type is required for this to work.

Functions

Link copied to clipboard
fun random(): UUID

A UUIDv4 — no timestamp component, for ids that must not leak their creation time.

Link copied to clipboard

A UUIDv7 (RFC 9562) — sortable by creation time when stored as a plain CQL uuid column.