Class: Aerospike::ExistsCommand

Inherits:
SingleCommand show all
Defined in:
lib/aerospike/command/exists_command.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Command

#execute, #set_batch_exists, #set_batch_get, #set_delete, #set_exists, #set_operate, #set_read, #set_read_for_key_only, #set_read_header, #set_scan, #set_touch, #set_udf, #set_write

Constructor Details

#initialize(cluster, policy, key) ⇒ ExistsCommand

Returns a new instance of ExistsCommand.



28
29
30
31
32
33
34
# File 'lib/aerospike/command/exists_command.rb', line 28

def initialize(cluster, policy, key)
  super(cluster, key)

  @policy = policy

  self
end

Instance Attribute Details

#existsObject (readonly)

Returns the value of attribute exists.



26
27
28
# File 'lib/aerospike/command/exists_command.rb', line 26

def exists
  @exists
end

Instance Method Details

#parse_resultObject



40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/aerospike/command/exists_command.rb', line 40

def parse_result
  # Read header.
  @conn.read(@data_buffer, MSG_TOTAL_HEADER_SIZE)

  result_code = @data_buffer.read(13).ord & 0xFF

  if (result_code != 0) && (result_code != Aerospike::ResultCode::KEY_NOT_FOUND_ERROR)
    raise Aerospike::Exceptions::Aerospike.new(result_code)
  end

  @exists = (result_code == 0)

  empty_socket
end

#write_bufferObject



36
37
38
# File 'lib/aerospike/command/exists_command.rb', line 36

def write_buffer
  set_exists(@policy, @key)
end