Module: Couchbase::Operations::Store
- Defined in:
- lib/couchbase/operations/store.rb
Instance Method Summary collapse
- #[]=(key, *args) ⇒ Object
-
#add(key, value, options = {}) {|ret| ... } ⇒ Fixnum
Add the item to the database, but fail if the object exists already.
-
#append(key, value, options = {}) ⇒ Fixnum
Append this object to the existing object.
- #async_add(key, value, options, &block) ⇒ Object
- #async_replace(key, value, options, &block) ⇒ Object
- #async_set(key, value, options, &block) ⇒ Object
-
#prepend(key, value, options = {}) ⇒ Object
Prepend this object to the existing object.
-
#replace(key, value, options = {}) ⇒ Fixnum
Replace the existing object in the database.
-
#set(key, value, options = {}) {|ret| ... } ⇒ Fixnum
Unconditionally store the object in the Couchbase.
Instance Method Details
#[]=(key, *args) ⇒ Object
114 115 116 117 118 119 |
# File 'lib/couchbase/operations/store.rb', line 114 def []=(key, *args) = args.size > 1 ? args.shift : {} value = args.pop set(key, value, ) end |
#add(key, value, options = {}) {|ret| ... } ⇒ Fixnum
Add the item to the database, but fail if the object exists already
170 171 172 173 174 175 176 177 178 179 180 181 |
# File 'lib/couchbase/operations/store.rb', line 170 def add(key, value = nil, = {}) if async? if block_given? async_add(key, value, , &Proc.new) else async_add(key, value, ) end else sync_block_error if block_given? store_op(:add, key, value, ) end end |
#append(key, value, options = {}) ⇒ Fixnum
This operation is kind of data-aware from server point of view. This mean that the server treats value as binary stream and just perform concatenation, therefore it won’t work with :marshal and :document formats, because of lack of knowledge how to merge values in these formats. See Bucket#cas for workaround.
Append this object to the existing object
318 319 320 321 |
# File 'lib/couchbase/operations/store.rb', line 318 def append(key, value) sync_block_error if block_given? store_op(:append, key, value) end |
#async_add(key, value, options, &block) ⇒ Object
183 184 185 |
# File 'lib/couchbase/operations/store.rb', line 183 def async_add(key, value, , &block) async_store_op(:add, key, value, , &block) end |
#async_replace(key, value, options, &block) ⇒ Object
241 242 243 |
# File 'lib/couchbase/operations/store.rb', line 241 def async_replace(key, value, , &block) async_store_op(:replace, key, value, , &block) end |
#async_set(key, value, options, &block) ⇒ Object
110 111 112 |
# File 'lib/couchbase/operations/store.rb', line 110 def async_set(key, value, , &block) async_store_op(:set, key, value, , &block) end |
#prepend(key, value, options = {}) ⇒ Object
This operation is kind of data-aware from server point of view. This mean that the server treats value as binary stream and just perform concatenation, therefore it won’t work with :marshal and :document formats, because of lack of knowledge how to merge values in these formats. See Bucket#cas for workaround.
Prepend this object to the existing object
375 376 377 378 |
# File 'lib/couchbase/operations/store.rb', line 375 def prepend(key, value) sync_block_error if block_given? store_op(:prepend, key, value) end |
#replace(key, value, options = {}) ⇒ Fixnum
Replace the existing object in the database
228 229 230 231 232 233 234 235 236 237 238 239 |
# File 'lib/couchbase/operations/store.rb', line 228 def replace(key, value, = {}) if async? if block_given? async_replace(key, value, , &Proc.new) else async_replace(key, value, ) end else sync_block_error if block_given? store_op(:replace, key, value, ) end end |
#set(key, value, options = {}) {|ret| ... } ⇒ Fixnum
Unconditionally store the object in the Couchbase
97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/couchbase/operations/store.rb', line 97 def set(key, value = nil, = {}) if async? if block_given? async_set(key, value, , &Proc.new) else async_set(key, value, ) end else sync_block_error if block_given? store_op(:set, key, value, ) end end |