libcouchbase 1.2.2 → 1.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +28 -43
- data/lib/libcouchbase/connection.rb +12 -7
- data/lib/libcouchbase/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 994ce5bef19d9b756a99b100151c0186c1196b1c
|
4
|
+
data.tar.gz: '04980977530cfe5f4c94f8eeb38c03546bcba541'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f3bd4838cdb3fcbca7825fb0b0bade82b4054c72526ab82720adb1d5e536b0e0367bd65d55f012f52cd223c08d6e67a113616d4c8280d99169656362a204b25
|
7
|
+
data.tar.gz: 50a3ed477e3fa3e7faa06081343ab5a570e738e53d6f071a54629defa764f2a3a6aa40be9444c2e38e77470b9284a3aad40de1082e7338fa170ae441d4adb88f
|
data/README.md
CHANGED
@@ -9,6 +9,19 @@ An alternative to the official [couchbase-client](https://github.com/couchbase/c
|
|
9
9
|
|
10
10
|
This is a low level wrapper around libcouchbase. For a more friendly ActiveModel interface see [couchbase-orm](https://github.com/acaprojects/couchbase-orm)
|
11
11
|
|
12
|
+
## Couchbase 5 Changes
|
13
|
+
|
14
|
+
The Couchbase 5 Admin Console blows away flags on documents if you edit them in the interface.
|
15
|
+
Flags were being used to store document formats, however these were mainly implemented for compatibility with the defunct official client.
|
16
|
+
|
17
|
+
|
18
|
+
To prevent this being an issue we've made the following changes from version 1.2 of this library:
|
19
|
+
|
20
|
+
1. All writes will result in valid JSON being saved to the database
|
21
|
+
* No more `raw strings` they will be saved as `"raw strings"`
|
22
|
+
* Existing raw strings will still be read correctly
|
23
|
+
2. Since there are no more raw strings, append / prepend are no longer needed (not that we ever used them)
|
24
|
+
|
12
25
|
|
13
26
|
## Runtime Support:
|
14
27
|
|
@@ -97,22 +110,6 @@ bucket.get("missing-key") #=> raise Libcouchbase::Error::KeyN
|
|
97
110
|
bucket.get("missing-key", :quiet => true) #=> nil
|
98
111
|
```
|
99
112
|
|
100
|
-
The library supports three different formats for representing values:
|
101
|
-
|
102
|
-
* `:document` (default) format supports most of ruby types which could
|
103
|
-
be mapped to JSON data (hashes, arrays, string, numbers).
|
104
|
-
|
105
|
-
* `:plain` This format avoids any conversions to be applied to your
|
106
|
-
data, but your data should be passed as String. This is useful for
|
107
|
-
building custom algorithms or formats.
|
108
|
-
|
109
|
-
* `:marshal` Use this format if you'd like to transparently serialize your
|
110
|
-
ruby object with standard `Marshal.dump` and `Marshal.load` methods
|
111
|
-
|
112
|
-
```ruby
|
113
|
-
bucket.put(:some_object, my_object, format: :marshal)
|
114
|
-
```
|
115
|
-
|
116
113
|
|
117
114
|
The library supports both synchronous and asynchronous operations.
|
118
115
|
In asynchronous mode all operations will return control to caller
|
@@ -125,8 +122,8 @@ to execute in parallel.
|
|
125
122
|
```ruby
|
126
123
|
# Perform operations in Async and then wait for the results
|
127
124
|
results = []
|
128
|
-
results << bucket.get(:key1)
|
129
|
-
results << bucket.get(:key2)
|
125
|
+
results << bucket.get(:key1, async: true)
|
126
|
+
results << bucket.get(:key2, async: true)
|
130
127
|
bucket.wait_results(results) #=> ['key1_val', 'key2_val']
|
131
128
|
|
132
129
|
# Is equivalent to:
|
@@ -153,7 +150,7 @@ result = bucket.get("foo", extended: true)
|
|
153
150
|
result.key #=> "foo"
|
154
151
|
result.value #=> {some: "value"}
|
155
152
|
result.cas #=> 123445
|
156
|
-
result.metadata #=> {
|
153
|
+
result.metadata #=> {flags: 0}
|
157
154
|
```
|
158
155
|
|
159
156
|
|
@@ -195,7 +192,7 @@ options as set command above.
|
|
195
192
|
|
196
193
|
```ruby
|
197
194
|
bucket.add("foo", "bar")
|
198
|
-
bucket.add("foo", "bar", ttl: 30
|
195
|
+
bucket.add("foo", "bar", ttl: 30)
|
199
196
|
```
|
200
197
|
|
201
198
|
|
@@ -209,20 +206,6 @@ bucket.replace("foo", "bar")
|
|
209
206
|
```
|
210
207
|
|
211
208
|
|
212
|
-
### Prepend/Append
|
213
|
-
|
214
|
-
These commands are meaningful when you are using the `:plain` value format,
|
215
|
-
because the concatenation is performed by server which has no idea how
|
216
|
-
to merge to JSON values or values in ruby Marshal format.
|
217
|
-
|
218
|
-
```ruby
|
219
|
-
bucket.set(:foo, "world", format: :plain)
|
220
|
-
bucket.append(:foo, "!")
|
221
|
-
bucket.prepend(:foo, "Hello, ")
|
222
|
-
bucket.get(:foo) #=> "Hello, world!"
|
223
|
-
```
|
224
|
-
|
225
|
-
|
226
209
|
### Increment/Decrement
|
227
210
|
|
228
211
|
These commands increment the value assigned to the key.
|
@@ -401,19 +384,21 @@ To execute view you need to fetch it from design document `_design/blog`:
|
|
401
384
|
If N1QL indexes have been created, then you can query them
|
402
385
|
|
403
386
|
```ruby
|
404
|
-
|
405
|
-
|
406
|
-
|
387
|
+
results = bucket.n1ql
|
388
|
+
.select('*')
|
389
|
+
.from(:default)
|
390
|
+
.where('port == 10001')
|
391
|
+
.results
|
407
392
|
|
408
393
|
# Results are lazily loaded by the enumerator
|
409
|
-
# Results are stored for re-use until `
|
394
|
+
# Results are stored for re-use until `results` goes out of scope
|
410
395
|
# Actual database query happens here
|
411
|
-
|
396
|
+
results.each do |row|
|
412
397
|
# Each row is a Hash of the data requested
|
413
398
|
end
|
414
399
|
|
415
400
|
# You can however stream results to save memory and the results are not saved
|
416
|
-
|
401
|
+
results.stream do |row|
|
417
402
|
# Row is cleaned up as soon as possible
|
418
403
|
end
|
419
404
|
```
|
@@ -424,17 +409,17 @@ end
|
|
424
409
|
If Full Text Search indexes have been created, then you can query them
|
425
410
|
|
426
411
|
```ruby
|
427
|
-
|
412
|
+
results = bucket.full_text_search(:index_name, 'query')
|
428
413
|
|
429
414
|
# Results are lazily loaded by the enumerator
|
430
415
|
# Results are stored for re-use until `res` goes out of scope
|
431
416
|
# Actual database query happens here
|
432
|
-
|
417
|
+
results.each do |row|
|
433
418
|
# Each row is a Hash of the data requested
|
434
419
|
end
|
435
420
|
|
436
421
|
# You can however stream results to save memory and the results are not saved
|
437
|
-
|
422
|
+
results.stream do |row|
|
438
423
|
# Row is cleaned up as soon as possible
|
439
424
|
end
|
440
425
|
```
|
@@ -780,11 +780,7 @@ module Libcouchbase
|
|
780
780
|
headers[key] = value
|
781
781
|
end
|
782
782
|
end
|
783
|
-
body =
|
784
|
-
resp[:body].read_string(resp[:nbody])
|
785
|
-
else
|
786
|
-
''
|
787
|
-
end
|
783
|
+
body = body_text(resp)
|
788
784
|
|
789
785
|
if (200...300).include? resp[:htstatus]
|
790
786
|
HttpResponse.new(cb, resp[:htstatus], headers, body, req.value)
|
@@ -835,7 +831,7 @@ module Libcouchbase
|
|
835
831
|
error_klass = Error.lookup(row_data[:rc])
|
836
832
|
if error_klass == Error::HttpError
|
837
833
|
http_resp = row_data[:htresp]
|
838
|
-
view.error error_klass.new(
|
834
|
+
view.error error_klass.new(body_text(http_resp))
|
839
835
|
else
|
840
836
|
view.error error_klass.new
|
841
837
|
end
|
@@ -871,11 +867,20 @@ module Libcouchbase
|
|
871
867
|
error_klass = Error.lookup(row_data[:rc])
|
872
868
|
if error_klass == Error::HttpError
|
873
869
|
http_resp = row_data[:htresp]
|
874
|
-
view.error error_klass.new(
|
870
|
+
view.error error_klass.new(body_text(http_resp))
|
875
871
|
else
|
876
872
|
view.error error_klass.new
|
877
873
|
end
|
878
874
|
end
|
879
875
|
end
|
876
|
+
|
877
|
+
# Extracts the body content of a HTTP response
|
878
|
+
def body_text(http_resp)
|
879
|
+
if http_resp[:nbody] > 0
|
880
|
+
http_resp[:body].read_string(http_resp[:nbody])
|
881
|
+
else
|
882
|
+
''
|
883
|
+
end
|
884
|
+
end
|
880
885
|
end
|
881
886
|
end
|
data/lib/libcouchbase/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: libcouchbase
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephen von Takach
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|