Class: Aerospike::ExistsCommand
- Inherits:
-
SingleCommand
- Object
- Command
- SingleCommand
- Aerospike::ExistsCommand
- Defined in:
- lib/aerospike/command/exists_command.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#exists ⇒ Object
readonly
Returns the value of attribute exists.
Instance Method Summary collapse
- #get_node ⇒ Object
-
#initialize(cluster, policy, key) ⇒ ExistsCommand
constructor
A new instance of ExistsCommand.
- #parse_result ⇒ Object
- #write_buffer ⇒ Object
Methods inherited from Command
#execute, #set_delete, #set_exists, #set_operate, #set_query, #set_read, #set_read_for_key_only, #set_read_header, #set_scan, #set_touch, #set_udf, #set_write, #write_bins
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
#exists ⇒ Object (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
#get_node ⇒ Object
36 37 38 |
# File 'lib/aerospike/command/exists_command.rb', line 36 def get_node @cluster.read_node(@partition, @policy.replica, @sequence) end |
#parse_result ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/aerospike/command/exists_command.rb', line 44 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 @exists = true return end if result_code == Aerospike::ResultCode::KEY_NOT_FOUND_ERROR @exists = false return end if result_code == Aerospike::ResultCode::FILTERED_OUT if @policy.fail_on_filtered_out raise Aerospike::Exceptions::Aerospike.new(result_code, nil, [@node]) end @exists = true return end raise Aerospike::Exceptions::Aerospike.new(result_code, nil, [@node]) end |
#write_buffer ⇒ Object
40 41 42 |
# File 'lib/aerospike/command/exists_command.rb', line 40 def write_buffer set_exists(@policy, @key) end |