class Aerospike::Record

Constants

CITRUSLEAF_EPOCH

Attributes

bins[R]
expiration[R]
generation[R]
key[R]
node[R]
ttl[R]

Public Class Methods

new(node, rec_key, rec_bins, rec_gen, rec_exp) click to toggle source
# File lib/aerospike/record.rb, line 28
def initialize(node, rec_key, rec_bins, rec_gen, rec_exp)
  @key = rec_key
  @bins = rec_bins
  @generation = rec_gen
  @ttl = expiration_to_ttl(rec_exp)
  @node = node
end

Public Instance Methods

to_s() click to toggle source
# File lib/aerospike/record.rb, line 38
def to_s
  "key: `#{key}` bins: `#{bins}` generation: `#{generation}`, ttl: `#{ttl}`"
end

Private Instance Methods

expiration_to_ttl(secs_from_epoc) click to toggle source

Converts an absolute expiration time (in seconds from citrusleaf epoch) to relative time-to-live (TTL) in seconds

# File lib/aerospike/record.rb, line 60
def expiration_to_ttl(secs_from_epoc)
  if secs_from_epoc == 0
    Aerospike::TTL::NEVER_EXPIRE
  else
    now = Time.now.to_i - CITRUSLEAF_EPOCH
    # Record was not expired at server but if it looks expired at client
    # because of delay or clock differences, present it as not-expired.
    secs_from_epoc > now ? secs_from_epoc - now : 1
  end
end
get_value(value) click to toggle source

Arguments:

value: the key to retrieve the value for

Returns:

the value of the specified key, or `nil` if `@bins` is `nil`
# File lib/aerospike/record.rb, line 51
def get_value(value)
  unless @bins.nil?
    return @bins[value]
  end
  nil
end