Class: Aerospike::WritePolicy

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

Overview

Container object for client policy command.

Instance Attribute Summary collapse

Attributes inherited from Policy

#consistency_level, #max_retries, #priority, #sleep_between_retries, #timeout

Instance Method Summary collapse

Constructor Details

#initialize(opt = {}) ⇒ WritePolicy

Returns a new instance of WritePolicy.



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
56
57
58
59
60
61
62
63
# File 'lib/aerospike/policy/write_policy.rb', line 29

def initialize(opt={})
  super(opt)

  # Qualify how to handle writes where the record already exists.
  @record_exists_action = opt[:record_exists_action] || RecordExistsAction::UPDATE

  # Qualify how to handle record writes based on record generation. The default (NONE)
  # indicates that the generation is not used to restrict writes.
  @generation_policy = opt[:gen_policy] || GenerationPolicy::NONE

  # Desired consistency guarantee when committing a transaction on the server. The default
  # (COMMIT_ALL) indicates that the server should wait for master and all replica commits to
  # be successful before returning success to the client.
  @commit_level = opt[:commit_level] || Aerospike::CommitLevel::COMMIT_ALL

  # Expected generation. Generation is the number of times a record has been modified
  # (including creation) on the server. If a write operation is creating a record,
  # the expected generation would be 0
  @generation = opt[:generation] || 0

  # Record expiration. Also known as ttl (time to live).
  # Seconds record will live before being removed by the server.
  # Expiration values:
  # -1: Never expire for Aerospike 2 server versions >= 2.7.2 and Aerospike 3 server
  # versions >= 3.1.4.  Do not use -1 for older servers.
  # 0: Default to namespace configuration variable "default-ttl" on the server.
  # > 0: Actual expiration in seconds.
  @expiration = opt[:expiration] || opt[:ttl] || 0

  # Send user defined key in addition to hash digest on a record put.
  # The default is to send the user defined key.
  @send_key = opt[:send_key].nil? ? true : send_key

  self
end

Instance Attribute Details

#commit_levelObject

Returns the value of attribute commit_level.



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

def commit_level
  @commit_level
end

#expirationObject

Returns the value of attribute expiration.



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

def expiration
  @expiration
end

#generationObject

Returns the value of attribute generation.



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

def generation
  @generation
end

#generation_policyObject

Returns the value of attribute generation_policy.



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

def generation_policy
  @generation_policy
end

#record_exists_actionObject

Returns the value of attribute record_exists_action.



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

def record_exists_action
  @record_exists_action
end

#send_keyObject

Returns the value of attribute send_key.



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

def send_key
  @send_key
end