Class: Aerospike::BatchWritePolicy

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

Overview

Policy attributes used in batch write commands.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opt = {}) ⇒ BatchWritePolicy

Returns a new instance of BatchWritePolicy.

[View source]

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
# File 'lib/aerospike/policy/batch_write_policy.rb', line 31

def initialize(opt={})
  # Optional expression filter. If filter_exp exists and evaluates to false, the specific batch key
  # request is not performed and {BatchRecord#result_code} is set to
  # {ResultCode#FILTERED_OUT}.
  #
  # If exists, this filter overrides the batch parent filter {Policy#filter_exp}
  # for the specific key in batch commands that allow a different policy per key.
  # Otherwise, this filter is ignored.
  #
  # Default: nil
  @filter_exp = opt[:filter_exp]

  # Qualify how to handle writes where the record already exists.
  #
  # Default: RecordExistsAction::UPDATE
  @record_exists_action = opt.fetch(:record_exists_action, RecordExistsAction::UPDATE)

  # 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.
  #
  # Default: CommitLevel::COMMIT_ALL
  @commit_level = opt.fetch(:commit_level, CommitLevel::COMMIT_ALL)

  # Qualify how to handle record writes based on record generation. The default (NONE)
  # indicates that the generation is not used to restrict writes.
  #
  # The server does not support this field for UDF execute() calls. The read-modify-write
  # usage model can still be enforced inside the UDF code itself.
  #
  # Default: GenerationPolicy::NONE
  @generation_policy = opt.fetch(:generation_policy, GenerationPolicy::NONE)

  # 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 <code>0</code>. This field is only relevant when
  # generationPolicy is not NONE.
  #
  # The server does not support this field for UDF execute() calls. The read-modify-write
  # usage model can still be enforced inside the UDF code itself.
  #
  # Default: 0
  @generation = opt.fetch(:generation, 0)

  # Record expiration; also known as time-to-live (TTL).
  # Seconds record will live before being removed by the server.
  #
  # Supported values:
  # - `Aerospike::TTL::NEVER_EXPIRE`: Never expire record; requires Aerospike 2
  #    server versions >= 2.7.2 or Aerospike 3 server versions >= 3.1.4. Do
  #    not use for older servers.
  # - `Aerospike::TTL::NAMESPACE_DEFAULT`: Default to namespace configuration
  #    variable "default-ttl" on the server.
  # - `Aerospike::TTL::DONT_UPDATE`: Do not change a record's expiration date
  #   when updating the record. Requires Aerospike server v3.10.1 or later.
  # - Any value > 0: Actual time-to-live in seconds.
  @ttl = opt[:ttl] || opt[:expiration] || 0

  # If the transaction results in a record deletion, leave a tombstone for the record.
  # This prevents deleted records from reappearing after node failures.
  # Valid for Aerospike Server Enterprise Edition only.
  #
  # Default: false (do not tombstone deleted records).
  @durable_delete = opt.fetch(:durable_delete, false)

  # Send user defined key in addition to hash digest.
  # If true, the key will be stored with the record on the server.
  #
  # Default: false (do not send the user defined key)
  @send_key = opt.fetch(:send_key, false)

  self
end

Instance Attribute Details

#commit_levelObject

Returns the value of attribute commit_level.


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

def commit_level
  @commit_level
end

#durable_deleteObject

Returns the value of attribute durable_delete.


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

def durable_delete
  @durable_delete
end

#filter_expObject

Returns the value of attribute filter_exp.


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

def filter_exp
  @filter_exp
end

#generationObject

Returns the value of attribute generation.


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

def generation
  @generation
end

#generation_policyObject

Returns the value of attribute generation_policy.


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

def generation_policy
  @generation_policy
end

#record_exists_actionObject

Returns the value of attribute record_exists_action.


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

def record_exists_action
  @record_exists_action
end

#send_keyObject

Returns the value of attribute send_key.


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

def send_key
  @send_key
end

#ttlObject Also known as: expiration

Returns the value of attribute ttl.


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

def ttl
  @ttl
end