class RethinkORM::IdGenerator

Overview

Generates time-sortable, collision resistant primary keys.

Provides suitable performance with local, high-frequency batch insertions and distributed operation will low collision probability. Generated ID's are in the form <prefix>-<postfix> where prefix defaults to the table name and postfix is a lexicographically sortable 10 character unique identifier.

Defined in:

rethinkdb-orm/utils/id_generator.cr

Constant Summary

ENCODING = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '-', '_', '~'}
RAND_GEN = seq(max: 2_u32 ** RAND_LEN)
RAND_LEN = 30

30-bits of entropy

TIME_OFFSET = (Time.utc(2014, 1, 1)).to_unix

Coverage to 2050 in 30 bits

Class Method Summary

Class Method Detail

def self.next(table_name : String) #

[View source]
def self.next(model) #

[View source]
def self.postfix #

[View source]