libcouchbase 1.2.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/libcouchbase/bucket.rb +0 -78
- data/lib/libcouchbase/connection.rb +4 -10
- data/lib/libcouchbase/version.rb +1 -1
- data/spec/connection_spec.rb +0 -25
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1b0ccfc76f819e532d866eb5696c4e442341ec00
|
4
|
+
data.tar.gz: d35f2ff5a08bd9c7e8b6909cca6ce3b0460f0772
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd66d502e5a684b84b46b33539cbf73fe5571a086131d08114c1974a36b836e606b2605d349ed6f5c54db842f2bd65fa1457888adc645e4f92f52c858e15a7c5
|
7
|
+
data.tar.gz: 65c567b06e3b65480c9d4876b5c56c54015f94c99630cf49d6a5b6626c79a4787d16783225c288539617e3437f6c4280864c58bcb1b1ce3ad992c6629d1b6542
|
data/lib/libcouchbase/bucket.rb
CHANGED
@@ -304,84 +304,6 @@ module Libcouchbase
|
|
304
304
|
end
|
305
305
|
ReplaceDefaults = {operation: :replace}.freeze
|
306
306
|
|
307
|
-
# Append this object to the existing object
|
308
|
-
#
|
309
|
-
# @param key [String, Symbol] Key used to reference the value.
|
310
|
-
# @param value [Object] Value to be appended
|
311
|
-
# @param options [Hash] Options for operation.
|
312
|
-
# @option options [Integer] :cas The CAS value for an object. This value is
|
313
|
-
# created on the server and is guaranteed to be unique for each value of
|
314
|
-
# a given key. This value is used to provide simple optimistic
|
315
|
-
# concurrency control when multiple clients or threads try to update an
|
316
|
-
# item simultaneously.
|
317
|
-
# @option options [Integer] :persist_to persist to a number of nodes before returing
|
318
|
-
# a result. Use -1 to persist to the maximum number of nodes
|
319
|
-
# @option options [Integer] :replicate_to replicate to a number of nodes before
|
320
|
-
# returning a result. Use -1 to replicate to the maximum number of nodes
|
321
|
-
#
|
322
|
-
# @return [Libcouchbase::Result] this includes the CAS value of the object.
|
323
|
-
#
|
324
|
-
# @raise [Libcouchbase::Error::KeyExists] if the key already exists on the server
|
325
|
-
# with a different CAS value to that provided
|
326
|
-
# @raise [Libouchbase::Error::Timedout] if timeout interval for observe exceeds
|
327
|
-
# @raise [Libouchbase::Error::NetworkError] if there was a communication issue
|
328
|
-
# @raise [Libcouchbase::Error::KeyNotFound] if the key doesn't exists
|
329
|
-
#
|
330
|
-
# @example Simple append
|
331
|
-
# c.set(:foo, "aaa")
|
332
|
-
# c.append(:foo, "bbb")
|
333
|
-
# c.get("foo") #=> "aaabbb"
|
334
|
-
#
|
335
|
-
# @example Using optimistic locking. The operation will fail on CAS mismatch
|
336
|
-
# resp = c.set("foo", "aaa")
|
337
|
-
# c.append("foo", "bbb", cas: resp.cas)
|
338
|
-
#
|
339
|
-
# @example Ensure that the key will be persisted at least on the one node
|
340
|
-
# c.append("foo", "bar", persist_to: 1)
|
341
|
-
def append(key, value, async: false, **opts)
|
342
|
-
result @connection.store(key, value, **AppendDefaults.merge(opts)), async
|
343
|
-
end
|
344
|
-
AppendDefaults = {operation: :append}.freeze
|
345
|
-
|
346
|
-
# Prepend this object to the existing object
|
347
|
-
#
|
348
|
-
# @param key [String, Symbol] Key used to reference the value.
|
349
|
-
# @param value [Object] Value to be appended
|
350
|
-
# @param options [Hash] Options for operation.
|
351
|
-
# @option options [Integer] :cas The CAS value for an object. This value is
|
352
|
-
# created on the server and is guaranteed to be unique for each value of
|
353
|
-
# a given key. This value is used to provide simple optimistic
|
354
|
-
# concurrency control when multiple clients or threads try to update an
|
355
|
-
# item simultaneously.
|
356
|
-
# @option options [Integer] :persist_to persist to a number of nodes before returing
|
357
|
-
# a result. Use -1 to persist to the maximum number of nodes
|
358
|
-
# @option options [Integer] :replicate_to replicate to a number of nodes before
|
359
|
-
# returning a result. Use -1 to replicate to the maximum number of nodes
|
360
|
-
#
|
361
|
-
# @return [Libcouchbase::Result] this includes the CAS value of the object.
|
362
|
-
#
|
363
|
-
# @raise [Libcouchbase::Error::KeyExists] if the key already exists on the server
|
364
|
-
# with a different CAS value to that provided
|
365
|
-
# @raise [Libouchbase::Error::Timedout] if timeout interval for observe exceeds
|
366
|
-
# @raise [Libouchbase::Error::NetworkError] if there was a communication issue
|
367
|
-
# @raise [Libcouchbase::Error::KeyNotFound] if the key doesn't exists
|
368
|
-
#
|
369
|
-
# @example Simple prepend
|
370
|
-
# c.set(:foo, "aaa")
|
371
|
-
# c.prepend(:foo, "bbb")
|
372
|
-
# c.get("foo") #=> "bbbaaa"
|
373
|
-
#
|
374
|
-
# @example Using optimistic locking. The operation will fail on CAS mismatch
|
375
|
-
# resp = c.set("foo", "aaa")
|
376
|
-
# c.prepend("foo", "bbb", cas: resp.cas)
|
377
|
-
#
|
378
|
-
# @example Ensure that the key will be persisted at least on the one node
|
379
|
-
# c.prepend("foo", "bar", persist_to: 1)
|
380
|
-
def prepend(key, value, async: false, **opts)
|
381
|
-
result @connection.store(key, value, **PrependDefaults.merge(opts)), async
|
382
|
-
end
|
383
|
-
PrependDefaults = {operation: :prepend}.freeze
|
384
|
-
|
385
307
|
# Increment the value of an existing numeric key
|
386
308
|
#
|
387
309
|
# The increment method allow you to increase or decrease a given stored
|
@@ -257,8 +257,6 @@ module Libcouchbase
|
|
257
257
|
defer.promise
|
258
258
|
end
|
259
259
|
|
260
|
-
NonJsonValue = [:append, :prepend].freeze
|
261
|
-
|
262
260
|
# http://docs.couchbase.com/sdk-api/couchbase-c-client-2.6.2/group__lcb-store.html
|
263
261
|
# http://docs.couchbase.com/sdk-api/couchbase-c-client-2.6.2/group__lcb-durability.html
|
264
262
|
def store(key, value,
|
@@ -287,14 +285,10 @@ module Libcouchbase
|
|
287
285
|
cmd[:operation] = operation
|
288
286
|
cmd[:flags] = flags
|
289
287
|
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
JSON.generate([value])[1..-2]
|
295
|
-
rescue
|
296
|
-
value.respond_to?(:to_str) ? value.to_str : value.to_s
|
297
|
-
end
|
288
|
+
str_value = begin
|
289
|
+
[value].to_json[1...-1]
|
290
|
+
rescue
|
291
|
+
[value.respond_to?(:to_str) ? value.to_str : value.to_s].to_json[1...-1]
|
298
292
|
end
|
299
293
|
|
300
294
|
req = Request.new(cmd, defer)
|
data/lib/libcouchbase/version.rb
CHANGED
data/spec/connection_spec.rb
CHANGED
@@ -26,31 +26,6 @@ describe Libcouchbase::Connection do
|
|
26
26
|
expect(@log).to eq([true])
|
27
27
|
end
|
28
28
|
|
29
|
-
it "should store a raw key on the bucket" do
|
30
|
-
@reactor.run { |reactor|
|
31
|
-
connection = Libcouchbase::Connection.new
|
32
|
-
connection.connect.then do
|
33
|
-
connection.store('sometestkey', 'rawdata', format: :plain).then(proc {|resp|
|
34
|
-
@log << resp.callback
|
35
|
-
prom = connection.store('sometestkey', 'moredata', operation: :append)
|
36
|
-
prom.then(proc { |success|
|
37
|
-
connection.get('sometestkey').then(proc {|resp|
|
38
|
-
@log << resp.value
|
39
|
-
}, proc { |error|
|
40
|
-
@log << error
|
41
|
-
})
|
42
|
-
}, proc { |error|
|
43
|
-
@log << error
|
44
|
-
})
|
45
|
-
}, proc { |error|
|
46
|
-
@log << error
|
47
|
-
}).finally { connection.destroy }
|
48
|
-
end
|
49
|
-
}
|
50
|
-
|
51
|
-
expect(@log).to eq([:callback_store, 'rawdatamoredata'])
|
52
|
-
end
|
53
|
-
|
54
29
|
it "should store a key on the default bucket" do
|
55
30
|
@reactor.run { |reactor|
|
56
31
|
connection = Libcouchbase::Connection.new
|