Class: Aerospike::Policy
- Inherits:
-
Object
- Object
- Aerospike::Policy
- Defined in:
- lib/aerospike/policy/policy.rb
Overview
Container object for client policy command.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#consistency_level ⇒ Object
Returns the value of attribute consistency_level.
-
#fail_on_filtered_out ⇒ Object
Returns the value of attribute fail_on_filtered_out.
-
#filter_exp ⇒ Object
Returns the value of attribute filter_exp.
-
#max_retries ⇒ Object
Returns the value of attribute max_retries.
-
#predexp ⇒ Object
Returns the value of attribute predexp.
-
#priority ⇒ Object
Returns the value of attribute priority.
-
#replica ⇒ Object
Returns the value of attribute replica.
-
#sleep_between_retries ⇒ Object
Returns the value of attribute sleep_between_retries.
-
#socket_timeout ⇒ Object
Returns the value of attribute socket_timeout.
-
#timeout ⇒ Object
(also: #total_timeout)
Returns the value of attribute timeout.
-
#use_compression ⇒ Object
Returns the value of attribute use_compression.
Instance Method Summary collapse
-
#initialize(opt = {}) ⇒ Policy
constructor
A new instance of Policy.
Constructor Details
#initialize(opt = {}) ⇒ Policy
Returns a new instance of Policy.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 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 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/aerospike/policy/policy.rb', line 30 def initialize(opt = {}) # Container object for transaction policy attributes used in all database # operation calls. # Optional expression filter. If filterExp exists and evaluates to false, the # transaction is ignored. # # Default: nil # # ==== Examples: # # p = Policy.new # p.filter_exp = Exp.build(Exp.eq(Exp.int_bin("a"), Exp.int_val(11))); @filter_exp = opt[:filter_exp] # Throw exception if {#filter_exp} is defined and that filter evaluates # to false (transaction ignored). The {AerospikeException} # will contain result code {ResultCode::FILTERED_OUT}. # # This field is not applicable to batch, scan or query commands. # # Default: false @fail_on_filtered_out = opt[:fail_on_filtered_out] || false # [:nodoc:] # DEPRECATED # The Aerospike server does not support this policy anymore # TODO: Remove for next major release @priority = opt[:priority] || Priority::DEFAULT # Set optional predicate expression filters in postfix notation. # Predicate expression filters are applied on the query results on the server. # Predicate expression filters may occur on any bin in the record. # Requires Aerospike Server versions >= 3.12 # # Postfix notation is described here: http://wiki.c2.com/?PostfixNotation # # Example: # # (c >= 11 and c <= 20) or (d > 3 and (d < 5) # policy.predexp = [ # PredExp.integer_bin("c"), # PredExp.integer_value(11), # PredExp.integer_greater_eq(), # PredExp.integer_bin("c"), # PredExp.integer_value(20), # PredExp.integer_less_eq(), # PredExp.and(2), # PredExp.integer_bin("d"), # PredExp.integer_value(3), # PredExp.integer_greater(), # PredExp.integer_bin("d"), # PredExp.integer_value(5), # PredExp.integer_less(), # PredExp.and(2), # PredExp.or(2) # ] # # # Record last update time > 2017-01-15 # policy.predexp = [ # PredExp.rec_last_update(), # PredExp.integer_value(Time.new(2017, 1, 15).to_i), # PredExp.integer_greater(), # PredExp.integer_greater() # ] @predexp = opt[:predexp] || nil # Throw exception if @predexp is defined and that filter evaluates # to false (transaction ignored). The Aerospike::Exceptions::Aerospike # will contain result code Aerospike::ResultCode::FILTERED_OUT. # This field is not applicable to batch, scan or query commands. @fail_on_filtered_out = opt[:fail_on_filtered_out] || false # How replicas should be consulted in a read operation to provide the desired # consistency guarantee. Default to allowing one replica to be used in the # read operation. @consistency_level = opt[:consistency_level] || Aerospike::ConsistencyLevel::CONSISTENCY_ONE # Send read commands to the node containing the key's partition replica type. # Write commands are not affected by this setting, because all writes are directed # to the node containing the key's master partition. # # Default to sending read commands to the node containing the key's master partition. @replica = opt[:replica] || Aerospike::Replica::MASTER # Use zlib compression on write or batch read commands when the command buffer size is greater # than 128 bytes. In addition, tell the server to compress its response on read commands. # The server response compression threshold is also 128 bytes. # # This option will increase cpu and memory usage (for extra compressed buffers), but # decrease the size of data sent over the network. @use_compression = opt[:use_compression] || false # Transaction timeout. # This timeout is used to set the socket timeout and is also sent to the # server along with the transaction in the wire protocol. # Default to no timeout (0). @timeout = opt[:timeout] || 0 # Maximum number of retries before aborting the current transaction. # A retry is attempted when there is a network error other than timeout. # If max_retries is exceeded, the abort will occur even if the timeout # has not yet been exceeded. @max_retries = opt[:max_retries] || 2 # Duration to sleep between retries if a transaction fails and the # timeout was not exceeded. Enter zero to skip sleep. @sleep_between_retries = opt[:sleep_between_retries] || 0.5 # Determines network timeout for each attempt. # # If socket_timeout is not zero and socket_timeout is reached before an attempt completes, # the Timeout above is checked. If Timeout is not exceeded, the transaction # is retried. If both socket_timeout and Timeout are non-zero, socket_timeout must be less # than or equal to Timeout, otherwise Timeout will also be used for socket_timeout. # # Default: 30s @socket_timeout = opt[:socket_timeout] || 30000 end |
Instance Attribute Details
#consistency_level ⇒ Object
Returns the value of attribute consistency_level.
24 25 26 |
# File 'lib/aerospike/policy/policy.rb', line 24 def consistency_level @consistency_level end |
#fail_on_filtered_out ⇒ Object
Returns the value of attribute fail_on_filtered_out.
24 25 26 |
# File 'lib/aerospike/policy/policy.rb', line 24 def fail_on_filtered_out @fail_on_filtered_out end |
#filter_exp ⇒ Object
Returns the value of attribute filter_exp.
24 25 26 |
# File 'lib/aerospike/policy/policy.rb', line 24 def filter_exp @filter_exp end |
#max_retries ⇒ Object
Returns the value of attribute max_retries.
24 25 26 |
# File 'lib/aerospike/policy/policy.rb', line 24 def max_retries @max_retries end |
#predexp ⇒ Object
Returns the value of attribute predexp.
24 25 26 |
# File 'lib/aerospike/policy/policy.rb', line 24 def predexp @predexp end |
#priority ⇒ Object
Returns the value of attribute priority.
24 25 26 |
# File 'lib/aerospike/policy/policy.rb', line 24 def priority @priority end |
#replica ⇒ Object
Returns the value of attribute replica.
24 25 26 |
# File 'lib/aerospike/policy/policy.rb', line 24 def replica @replica end |
#sleep_between_retries ⇒ Object
Returns the value of attribute sleep_between_retries.
24 25 26 |
# File 'lib/aerospike/policy/policy.rb', line 24 def sleep_between_retries @sleep_between_retries end |
#socket_timeout ⇒ Object
Returns the value of attribute socket_timeout.
24 25 26 |
# File 'lib/aerospike/policy/policy.rb', line 24 def socket_timeout @socket_timeout end |
#timeout ⇒ Object Also known as: total_timeout
Returns the value of attribute timeout.
24 25 26 |
# File 'lib/aerospike/policy/policy.rb', line 24 def timeout @timeout end |
#use_compression ⇒ Object
Returns the value of attribute use_compression.
24 25 26 |
# File 'lib/aerospike/policy/policy.rb', line 24 def use_compression @use_compression end |