Class: Cassandra::TimestampGenerator::Simple

Inherits:
Object
  • Object
show all
Includes:
Cassandra::TimestampGenerator
Defined in:
lib/cassandra/timestamp_generator/simple.rb

Overview

Note:

It is not appropriate for use with JRuby because its Time#now returns millisecond precision time.

Generate long integer timestamps from current time. This implementation relies on the Time class to return microsecond precision time.

Instance Method Summary collapse

Instance Method Details

#nextInteger

Create a new timestamp, as a 64-bit integer. This is just a wrapper around Time::now.



30
31
32
33
34
35
# File 'lib/cassandra/timestamp_generator/simple.rb', line 30

def next
  # Use Time.now, which has microsecond precision on MRI (and probably Rubinius) to make an int representing
  # client timestamp in protocol requests.
  timestamp = ::Time.now
  timestamp.tv_sec * 1000000 + timestamp.tv_usec
end