Skip to content

Commit

Permalink
convert expiry time to TTL in seconds in batch & query result
Browse files Browse the repository at this point in the history
Fixes #38.
  • Loading branch information
jhecking committed Aug 16, 2016
1 parent 0198995 commit bac2c2a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
8 changes: 4 additions & 4 deletions lib/aerospike/command/batch_command_get.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ def parse_record_results(receive_size)
# If cmd is the end marker of the response, do not proceed further
return false if (info3 & INFO3_LAST) == INFO3_LAST

generation = @data_buffer.read_int32(6).ord
expiration = @data_buffer.read_int32(10).ord
field_count = @data_buffer.read_int16(18).ord
op_count = @data_buffer.read_int16(20).ord
generation = @data_buffer.read_int32(6)
expiration = Aerospike.TTL(@data_buffer.read_int32(10))
field_count = @data_buffer.read_int16(18)
op_count = @data_buffer.read_int16(20)
key = parse_key(field_count)
item = @key_map[key.digest]

Expand Down
2 changes: 1 addition & 1 deletion lib/aerospike/query/stream_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def parse_record_results(receive_size)
return false if (info3 & INFO3_LAST) == INFO3_LAST

generation = @data_buffer.read_int32(6)
expiration = @data_buffer.read_int32(10)
expiration = Aerospike.TTL(@data_buffer.read_int32(10))
field_count = @data_buffer.read_int16(18)
op_count = @data_buffer.read_int16(20)
key = parse_key(field_count)
Expand Down
6 changes: 4 additions & 2 deletions spec/aerospike/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -623,8 +623,8 @@ def cluster_seeds(client)
key3 = Support.gen_random_key

bin = Aerospike::Bin.new('bin', 'value')
client.put(key1, bin)
client.put(key3, bin)
client.put(key1, bin, ttl: 1000)
client.put(key3, bin, ttl: 1000)

records = client.batch_get_header([key1, key2, key3])

Expand All @@ -633,12 +633,14 @@ def cluster_seeds(client)
expect(records[0].key).to eq key1
expect(records[0].bins).to be nil
expect(records[0].generation).to be 1
expect(records[0].expiration).to be_within(10).of(1000)

expect(records[1]).to be nil

expect(records[2].key).to eq key3
expect(records[2].bins).to be nil
expect(records[2].generation).to be 1
expect(records[2].expiration).to be_within(10).of(1000)

end

Expand Down

0 comments on commit bac2c2a

Please sign in to comment.