Class: Aerospike::Policy

Inherits:
Object
  • Object
show all
Defined in:
lib/aerospike/policy/policy.rb

Overview

Container object for client policy command.

Direct Known Subclasses

BatchPolicy, WritePolicy

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opt = {}) ⇒ Policy

Returns a new instance of Policy.



27
28
29
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
# File 'lib/aerospike/policy/policy.rb', line 27

def initialize(opt={})
  # Container object for transaction policy attributes used in all database
  # operation calls.

  # Priority of request relative to other transactions.
  # Currently, only used for scans.
  @priority = opt[:priority] || Priority::DEFAULT

  # 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

  # 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_retiries] || 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
end

Instance Attribute Details

#consistency_levelObject

Returns the value of attribute consistency_level.



25
26
27
# File 'lib/aerospike/policy/policy.rb', line 25

def consistency_level
  @consistency_level
end

#max_retriesObject

Returns the value of attribute max_retries.



25
26
27
# File 'lib/aerospike/policy/policy.rb', line 25

def max_retries
  @max_retries
end

#priorityObject

Returns the value of attribute priority.



25
26
27
# File 'lib/aerospike/policy/policy.rb', line 25

def priority
  @priority
end

#sleep_between_retriesObject

Returns the value of attribute sleep_between_retries.



25
26
27
# File 'lib/aerospike/policy/policy.rb', line 25

def sleep_between_retries
  @sleep_between_retries
end

#timeoutObject

Returns the value of attribute timeout.



25
26
27
# File 'lib/aerospike/policy/policy.rb', line 25

def timeout
  @timeout
end