Class: Aerospike::CDT::ListOperation
- Inherits:
-
Object
- Object
- Aerospike::CDT::ListOperation
- Defined in:
- lib/aerospike/cdt/list_operation.rb
Overview
List bin operations. Create list operations used by the Client#operate command. List operations support negative indexing. If the index is negative, the resolved index starts backwards from end of list.
Index/Range examples:
-
Index 0: First item in list.
-
Index 4: Fifth item in list.
-
Index -1: Last item in list.
-
Index -3: Third to last item in list.
-
Index 1 Count 2: Second and third items in list.
-
Index -3 Count 3: Last three items in list.
-
Index -5 Count 4: Range between fifth to last item to second to last item inclusive.
If an index is out of bounds, a parameter error will be returned. If a range is partially out of bounds, the valid part of the range will be returned.
Constant Summary collapse
- APPEND =
1- APPEND_ITEMS =
2- INSERT =
3- INSERT_ITEMS =
4- POP =
5- POP_RANGE =
6- REMOVE =
7- REMOVE_RANGE =
8- SET =
9- TRIM =
10- CLEAR =
11- INCREMENT =
12- SIZE =
16- GET =
17- GET_RANGE =
18
Class Method Summary collapse
-
.append(bin_name, *values) ⇒ Object
Create list append operation.
-
.clear(bin_name) ⇒ Object
Create list clear operation.
-
.get(bin_name, index) ⇒ Object
Create list get operation.
-
.get_range(bin_name, index, count = nil) ⇒ Object
Create list get range operation.
-
.increment(bin_name, index, value = nil) ⇒ Object
Create list increment operation.
-
.insert(bin_name, index, *values) ⇒ Object
Create list insert operation.
-
.pop(bin_name, index) ⇒ Object
Create list pop operation.
-
.pop_range(bin_name, index, count = nil) ⇒ Object
Create list pop range operation.
-
.remove(bin_name, index) ⇒ Object
Create list remove operation.
-
.remove_range(bin_name, index, count = nil) ⇒ Object
Create list remove range operation.
-
.set(bin_name, index, value) ⇒ Object
Create list set operation.
-
.size(bin_name) ⇒ Object
Create list size operation.
-
.trim(bin_name, index, count = nil) ⇒ Object
Create list trim operation.
Class Method Details
.append(bin_name, *values) ⇒ Object
Create list append operation.
Server appends value(s) to end of the list bin.
Server returns list size.
61 62 63 64 65 66 67 |
# File 'lib/aerospike/cdt/list_operation.rb', line 61 def self.append(bin_name, *values) if values.length > 1 create_operation(Operation::CDT_MODIFY, APPEND_ITEMS, bin_name, values) else create_operation(Operation::CDT_MODIFY, APPEND, bin_name, values.first) end end |
.clear(bin_name) ⇒ Object
Create list clear operation. Server removes all items in the list bin. Server does not return a result by default.
150 151 152 |
# File 'lib/aerospike/cdt/list_operation.rb', line 150 def self.clear(bin_name) create_operation(Operation::CDT_MODIFY, CLEAR, bin_name) end |
.get(bin_name, index) ⇒ Object
Create list get operation. Server returns the item at the specified index in the list bin.
176 177 178 |
# File 'lib/aerospike/cdt/list_operation.rb', line 176 def self.get(bin_name, index) create_operation(Operation::CDT_READ, GET, bin_name, index) end |
.get_range(bin_name, index, count = nil) ⇒ Object
Create list get range operation. Server returns “count” items starting at the specified index in the list bin. If “count” is not specified, the server returns all items starting at the specified index to the end of the list.
185 186 187 188 189 190 191 |
# File 'lib/aerospike/cdt/list_operation.rb', line 185 def self.get_range(bin_name, index, count=nil) if count create_operation(Operation::CDT_READ, GET_RANGE, bin_name, index, count) else create_operation(Operation::CDT_READ, GET_RANGE, bin_name, index) end end |
.increment(bin_name, index, value = nil) ⇒ Object
158 159 160 161 162 163 164 |
# File 'lib/aerospike/cdt/list_operation.rb', line 158 def self.increment(bin_name, index, value = nil) if value create_operation(Operation::CDT_MODIFY, INCREMENT, bin_name, index, value) else create_operation(Operation::CDT_MODIFY, INCREMENT, bin_name, index) end end |
.insert(bin_name, index, *values) ⇒ Object
Create list insert operation.
Server inserts value(s) at the specified index of the list bin.
Server returns list size.
73 74 75 76 77 78 79 |
# File 'lib/aerospike/cdt/list_operation.rb', line 73 def self.insert(bin_name, index, *values) if values.length > 1 create_operation(Operation::CDT_MODIFY, INSERT_ITEMS, bin_name, index, values) else create_operation(Operation::CDT_MODIFY, INSERT, bin_name, index, values.first) end end |
.pop(bin_name, index) ⇒ Object
Create list pop operation. Server returns item at specified index and removes item from list bin.
84 85 86 |
# File 'lib/aerospike/cdt/list_operation.rb', line 84 def self.pop(bin_name, index) create_operation(Operation::CDT_MODIFY, POP, bin_name, index) end |
.pop_range(bin_name, index, count = nil) ⇒ Object
Create list pop range operation. Server returns “count” items starting at specified index and removes items from list bin. If “count” is not specified, the server returns items starting at the specified index to the end of the list and removes those items from the list bin.
94 95 96 97 98 99 100 |
# File 'lib/aerospike/cdt/list_operation.rb', line 94 def self.pop_range(bin_name, index, count=nil) if count create_operation(Operation::CDT_MODIFY, POP_RANGE, bin_name, index, count) else create_operation(Operation::CDT_MODIFY, POP_RANGE, bin_name, index) end end |
.remove(bin_name, index) ⇒ Object
Create list remove operation. Server removes item at specified index from list bin. Server returns number of items removed.
106 107 108 |
# File 'lib/aerospike/cdt/list_operation.rb', line 106 def self.remove(bin_name, index) create_operation(Operation::CDT_MODIFY, REMOVE, bin_name, index) end |
.remove_range(bin_name, index, count = nil) ⇒ Object
Create list remove range operation. Server removes “count” items at specified index from list bin. If “count” is not specified, the server removes all items starting at the specified index to the end of the list. Server returns number of items removed.
116 117 118 119 120 121 122 |
# File 'lib/aerospike/cdt/list_operation.rb', line 116 def self.remove_range(bin_name, index, count=nil) if count create_operation(Operation::CDT_MODIFY, REMOVE_RANGE, bin_name, index, count) else create_operation(Operation::CDT_MODIFY, REMOVE_RANGE, bin_name, index) end end |
.set(bin_name, index, value) ⇒ Object
Create list set operation. Server sets item value at specified index in list bin. Server does not return a result by default.
128 129 130 |
# File 'lib/aerospike/cdt/list_operation.rb', line 128 def self.set(bin_name, index, value) create_operation(Operation::CDT_MODIFY, SET, bin_name, index, value) end |
.size(bin_name) ⇒ Object
Create list size operation. Server returns size of list.
169 170 171 |
# File 'lib/aerospike/cdt/list_operation.rb', line 169 def self.size(bin_name) create_operation(Operation::CDT_READ, SIZE, bin_name) end |
.trim(bin_name, index, count = nil) ⇒ Object
Create list trim operation. Server removes items in list bin that do not fall into range specified by index and count. If count is not specified, server will keep all items starting at the specified index to the end of the list. Server returns number of items removed.
138 139 140 141 142 143 144 |
# File 'lib/aerospike/cdt/list_operation.rb', line 138 def self.trim(bin_name, index, count=nil) if count create_operation(Operation::CDT_MODIFY, TRIM, bin_name, index, count) else create_operation(Operation::CDT_MODIFY, TRIM, bin_name, index) end end |