class Cassandra::Uuid::Generator
A UUID generator.
This class can be used to genereate Apache Cassandra timeuuid and uuid values.
- Note
- Instances of this class are absolutely not threadsafe. You should never share instances between threads.
Inherits
Object
Methods
new
(node_id = (::SecureRandom.random_number(2**47) | 0x010000000000), clock_id = ::SecureRandom.random_number(65536), clock = ::Time)Create a new UUID generator.
The clock ID and node ID components are set to random numbers when the generator is created. These are used for generation of time UUIDs only.
now
Returns a new UUID with a time component that is the current time.
If two calls to #now
happen within the time afforded by the system
clock resolution a counter is incremented and added to the time
component.
If the clock moves backwards the clock ID is reset to a new random number.
at
(*args)Returns a new UUID with a time component based on the specified Time. A piece of jitter is added to ensure that multiple calls with the same time do not generate the same UUID (if you want determinism you can set the second parameter to zero).
- Note
- the
jitter
argument accepted by all variants of this method is required to add randomness to generatedTimeUuid
and might affect the order of generated timestamps. You should setjitter
to 0 when the source time(stamp)s are unique.
uuid
Returns a completely random version 4 UUID.