couchbase 1.3.4-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +15 -0
  3. data/.travis.yml +22 -0
  4. data/.yardopts +5 -0
  5. data/CONTRIBUTING.markdown +75 -0
  6. data/Gemfile +4 -0
  7. data/LICENSE +201 -0
  8. data/Makefile +3 -0
  9. data/README.markdown +649 -0
  10. data/RELEASE_NOTES.markdown +796 -0
  11. data/Rakefile +20 -0
  12. data/couchbase.gemspec +49 -0
  13. data/examples/chat-em/Gemfile +7 -0
  14. data/examples/chat-em/README.markdown +45 -0
  15. data/examples/chat-em/server.rb +82 -0
  16. data/examples/chat-goliath-grape/Gemfile +5 -0
  17. data/examples/chat-goliath-grape/README.markdown +50 -0
  18. data/examples/chat-goliath-grape/app.rb +67 -0
  19. data/examples/chat-goliath-grape/config/app.rb +20 -0
  20. data/examples/transcoders/Gemfile +3 -0
  21. data/examples/transcoders/README.markdown +59 -0
  22. data/examples/transcoders/cb-zcat +40 -0
  23. data/examples/transcoders/cb-zcp +45 -0
  24. data/examples/transcoders/gzip_transcoder.rb +49 -0
  25. data/examples/transcoders/options.rb +54 -0
  26. data/ext/couchbase_ext/.gitignore +4 -0
  27. data/ext/couchbase_ext/arguments.c +956 -0
  28. data/ext/couchbase_ext/arithmetic.c +307 -0
  29. data/ext/couchbase_ext/bucket.c +1370 -0
  30. data/ext/couchbase_ext/context.c +65 -0
  31. data/ext/couchbase_ext/couchbase_ext.c +1364 -0
  32. data/ext/couchbase_ext/couchbase_ext.h +644 -0
  33. data/ext/couchbase_ext/delete.c +163 -0
  34. data/ext/couchbase_ext/eventmachine_plugin.c +452 -0
  35. data/ext/couchbase_ext/extconf.rb +168 -0
  36. data/ext/couchbase_ext/get.c +316 -0
  37. data/ext/couchbase_ext/gethrtime.c +129 -0
  38. data/ext/couchbase_ext/http.c +432 -0
  39. data/ext/couchbase_ext/multithread_plugin.c +1090 -0
  40. data/ext/couchbase_ext/observe.c +171 -0
  41. data/ext/couchbase_ext/plugin_common.c +171 -0
  42. data/ext/couchbase_ext/result.c +129 -0
  43. data/ext/couchbase_ext/stats.c +163 -0
  44. data/ext/couchbase_ext/store.c +542 -0
  45. data/ext/couchbase_ext/timer.c +192 -0
  46. data/ext/couchbase_ext/touch.c +186 -0
  47. data/ext/couchbase_ext/unlock.c +176 -0
  48. data/ext/couchbase_ext/utils.c +551 -0
  49. data/ext/couchbase_ext/version.c +142 -0
  50. data/lib/action_dispatch/middleware/session/couchbase_store.rb +38 -0
  51. data/lib/active_support/cache/couchbase_store.rb +430 -0
  52. data/lib/couchbase.rb +155 -0
  53. data/lib/couchbase/bucket.rb +457 -0
  54. data/lib/couchbase/cluster.rb +119 -0
  55. data/lib/couchbase/connection_pool.rb +58 -0
  56. data/lib/couchbase/constants.rb +12 -0
  57. data/lib/couchbase/result.rb +26 -0
  58. data/lib/couchbase/transcoder.rb +120 -0
  59. data/lib/couchbase/utils.rb +62 -0
  60. data/lib/couchbase/version.rb +21 -0
  61. data/lib/couchbase/view.rb +506 -0
  62. data/lib/couchbase/view_row.rb +272 -0
  63. data/lib/ext/multi_json_fix.rb +56 -0
  64. data/lib/rack/session/couchbase.rb +108 -0
  65. data/tasks/benchmark.rake +6 -0
  66. data/tasks/compile.rake +158 -0
  67. data/tasks/test.rake +100 -0
  68. data/tasks/util.rake +21 -0
  69. data/test/profile/.gitignore +1 -0
  70. data/test/profile/Gemfile +6 -0
  71. data/test/profile/benchmark.rb +195 -0
  72. data/test/setup.rb +178 -0
  73. data/test/test_arithmetic.rb +185 -0
  74. data/test/test_async.rb +316 -0
  75. data/test/test_bucket.rb +250 -0
  76. data/test/test_cas.rb +235 -0
  77. data/test/test_couchbase.rb +77 -0
  78. data/test/test_couchbase_connection_pool.rb +77 -0
  79. data/test/test_couchbase_rails_cache_store.rb +361 -0
  80. data/test/test_delete.rb +120 -0
  81. data/test/test_errors.rb +82 -0
  82. data/test/test_eventmachine.rb +70 -0
  83. data/test/test_format.rb +164 -0
  84. data/test/test_get.rb +407 -0
  85. data/test/test_stats.rb +57 -0
  86. data/test/test_store.rb +216 -0
  87. data/test/test_timer.rb +42 -0
  88. data/test/test_touch.rb +97 -0
  89. data/test/test_unlock.rb +119 -0
  90. data/test/test_utils.rb +58 -0
  91. data/test/test_version.rb +52 -0
  92. metadata +336 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a1cc85fb86da92840fadcda23fd9961a45165306
4
+ data.tar.gz: 47844601752a2dcc335681043f5e766b70042fd8
5
+ SHA512:
6
+ metadata.gz: 3c20878cbf421d74cba350c578020adc7f8e82a711ad37bbfc772f9aadf15856765e5201b77f4b78de5710a6f97ef0ad63aee1648001df5987b4ea4d24efd225
7
+ data.tar.gz: 2f2190494a0bb4531c5f2315c91f81f524361b6d5a9a017c2766d4405dc509ab6a81957ec7bcd5378e61db609ec936826a626d029e04e3e51954d7fe1e479731
data/.gitignore ADDED
@@ -0,0 +1,15 @@
1
+ *.bundle
2
+ *.gem
3
+ *.so
4
+ .timestamp
5
+ .yardoc
6
+ Gemfile.lock
7
+ core*
8
+ doc/
9
+ ext/couchbase/Makefile
10
+ ext/couchbase/mkmf.log
11
+ lib/couchbase_ext.rb
12
+ pkg/*
13
+ ports
14
+ test/CouchbaseMock.jar
15
+ tmp
data/.travis.yml ADDED
@@ -0,0 +1,22 @@
1
+ before_install:
2
+ - sudo rm -rf /etc/apt/sources.list.d/couchdb-ppa-source.list
3
+ - sudo rm -rf /etc/apt/sources.list.d/mongodb.list
4
+ - sudo rm -rf /etc/apt/sources.list.d/datastax-source.list
5
+ - sudo rm -rf /etc/apt/sources.list.d/rabbitmq-source.list
6
+ - sudo rm -rf /etc/apt/sources.list.d/mapopa-source.list
7
+ - sudo rm -rf /etc/apt/sources.list.d/webupd8team-java-ppa-source.list
8
+ - sudo rm -rf /etc/apt/sources.list.d/maven3-ppa-source.list
9
+ - wget -O- http://packages.couchbase.com/ubuntu/couchbase.key | sudo apt-key add -
10
+ - echo deb http://packages.couchbase.com/snapshot/ubuntu oneiric oneiric/main | sudo tee /etc/apt/sources.list.d/couchbase.list
11
+ - sudo apt-get update
12
+ - sudo apt-get -y install libcouchbase2-dev
13
+
14
+ rvm:
15
+ - 1.8.7
16
+ - 1.9.2
17
+ - 1.9.3
18
+ - ree
19
+
20
+ notifications:
21
+ email:
22
+ - sergey@couchbase.com
data/.yardopts ADDED
@@ -0,0 +1,5 @@
1
+ --protected
2
+ --no-private
3
+ -
4
+ README.markdown
5
+ RELEASE_NOTES.markdown
@@ -0,0 +1,75 @@
1
+ We've decided to use "gerrit" for our code review system, making it
2
+ easier for all of us to contribute with code and comments.
3
+
4
+ 1. Visit http://review.couchbase.org and "Register" for an account
5
+ 2. Review http://review.couchbase.org/static/individual_agreement.html
6
+ 3. Agree to agreement by visiting http://review.couchbase.org/#/settings/agreements
7
+ 4. If you do not receive an email, please contact us
8
+ 5. Check out the `couchbase-ruby-client` area http://review.couchbase.org/#/q/status:open+project:couchbase-ruby-client,n,z
9
+ 6. Join us on IRC at #libcouchbase on Freenode :-)
10
+
11
+ We normally don't go looking for stuff in gerrit, so you should add at
12
+ least me `"Sergey Avseyev" <sergey.avseyev@gmail.com>` as a reviewer
13
+ for your patch (and I'll know who else to add and add them for you).
14
+
15
+ ## Contributing Using Repo Tool
16
+
17
+ Follow ["Uploading Changes" guide][1] on the site if you have some code to contribute.
18
+
19
+ All you should need to set up your development environment should be:
20
+
21
+ ~ % mkdir couchbase-ruby
22
+ ~ % cd couchbase-ruby
23
+ ~/couchbase-ruby % repo init -u git://github.com/trondn/manifests.git -m ruby.xml
24
+ ~/couchbase-ruby % repo sync
25
+ ~/couchbase-ruby % repo start my-branch-name --all
26
+ ~/couchbase-ruby % make
27
+
28
+ This will build the latest version of `libcouchbase`,
29
+ `couchbase-ruby-client` and `couchbase-ruby-client` libraries. You must
30
+ have a C and C++ compiler installed, automake, autoconf.
31
+
32
+ If you have to make any changes just commit them before you upload
33
+ them to gerrit with the following command:
34
+
35
+ ~/couchbase-ruby/client % repo upload
36
+
37
+ You might experience a problem trying to upload the patches if you've
38
+ selected a different login name at http://review.couchbase.org than
39
+ your login name. Don't worry, all you need to do is to add the
40
+ following to your ~/.gitconfig file:
41
+
42
+ [review "review.couchbase.org"]
43
+ username = YOURNAME
44
+
45
+ ## Contributing Using Plain Git
46
+
47
+ If you not so familiar with repo tool and its workflow there is
48
+ alternative way to do the same job. Lets assume you have installed
49
+ couchbase gem and libcouchbase from official packages and would you to
50
+ contribute to couchbase-client gem only. Then you just need to complete
51
+ gerrit registration steps above and clone the source repository
52
+ (remember the repository on github.com is just a mirror):
53
+
54
+ ~ % git clone ssh://YOURNAME@review.couchbase.org:29418/couchbase-ruby-client.git
55
+
56
+ Install [`commit-msg` hook][2]:
57
+
58
+ ~/couchbase-ruby-client % scp -p -P 29418 YOURNAME@review.couchbase.org:hooks/commit-msg .git/hooks/
59
+
60
+ Make your changes and upload them for review:
61
+
62
+ ~/couchbase-ruby-client % git commit
63
+ ~/couchbase-ruby-client % git push origin HEAD:refs/for/master
64
+
65
+ If you need to fix or add something to your patch, do it and re-upload
66
+ the changes (all you need is to keep `Change-Id:` line the same to
67
+ allow gerrit to track the patch.
68
+
69
+ ~/couchbase-ruby-client % git commit --amend
70
+ ~/couchbase-ruby-client % git push origin HEAD:refs/for/master
71
+
72
+ Happy hacking!
73
+
74
+ [1]: http://review.couchbase.org/Documentation/user-upload.html
75
+ [2]: http://review.couchbase.org/Documentation/user-changeid.html
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in couchbase.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
data/Makefile ADDED
@@ -0,0 +1,3 @@
1
+ all:
2
+ $(MAKE) -C../.. ruby-client
3
+
data/README.markdown ADDED
@@ -0,0 +1,649 @@
1
+ # Couchbase Ruby Client
2
+
3
+ This is the official client library for use with Couchbase Server. There
4
+ are related libraries available:
5
+
6
+ * [couchbase-model][6] the ActiveModel implementation, git repository:
7
+ [https://github.com/couchbase/couchbase-ruby-model][7]
8
+
9
+ ## SUPPORT
10
+
11
+ If you find an issue, please file it in our [JIRA][1]. Also you are
12
+ always welcome on the `#libcouchbase` channel at [freenode.net IRC servers][2].
13
+
14
+ Documentation: [http://docs.couchbase.com/couchbase-sdk-ruby-1.3/](http://docs.couchbase.com/couchbase-sdk-ruby-1.3/)
15
+ API Documentation: [http://www.couchbase.com/autodocs/](http://www.couchbase.com/autodocs/)
16
+
17
+ ## INSTALL
18
+
19
+ This gem depends [libcouchbase][3]. In most cases installing
20
+ libcouchbase doesn't take much effort.
21
+
22
+ ### MacOS (Homebrew)
23
+
24
+ $ brew install libcouchbase
25
+
26
+ The official homebrew repository contains only stable versions of
27
+ libvbucket and libcouchbase, if you need preview, take a look at
28
+ Couchbase's fork: https://github.com/couchbase/homebrew
29
+
30
+ $ brew install https://raw.github.com/couchbase/homebrew/preview/Library/Formula/libcouchbase.rb
31
+
32
+ ### Debian (Ubuntu)
33
+
34
+ Add the appropriate line to `/etc/apt/sources.list.d/couchbase.list` for
35
+ your OS release:
36
+
37
+ # Ubuntu 11.10 Oneiric Ocelot (Debian unstable)
38
+ deb http://packages.couchbase.com/ubuntu oneiric oneiric/main
39
+
40
+ # Ubuntu 10.04 Lucid Lynx (Debian stable or testing)
41
+ deb http://packages.couchbase.com/ubuntu lucid lucid/main
42
+
43
+ Import the Couchbase PGP key:
44
+
45
+ wget -O- http://packages.couchbase.com/ubuntu/couchbase.key | sudo apt-key add -
46
+
47
+ Then install them
48
+
49
+ $ sudo apt-get update && sudo apt-get install libcouchbase-dev
50
+
51
+ Again, if you need a preview of a future version, just use another repository in
52
+ your `couchbase.list`
53
+
54
+ # Ubuntu 11.10 Oneiric Ocelot (Debian unstable)
55
+ deb http://packages.couchbase.com/preview/ubuntu oneiric oneiric/main
56
+
57
+ # Ubuntu 10.04 Lucid Lynx (Debian stable or testing)
58
+ deb http://packages.couchbase.com/preview/ubuntu lucid lucid/main
59
+
60
+ ### Centos (Redhat and rpm-based systems)
61
+
62
+ Add these lines to /etc/yum.repos.d/couchbase.repo using the correct architecture
63
+
64
+ [couchbase]
65
+ name = Couchbase package repository
66
+ baseurl = http://packages.couchbase.com/rpm/5.5/i386
67
+
68
+ [couchbase]
69
+ name = Couchbase package repository
70
+ baseurl = http://packages.couchbase.com/rpm/5.5/x86_64
71
+
72
+ Then to install libcouchbase itself, run:
73
+
74
+ $ sudo yum update && sudo yum install libcouchbase-devel
75
+
76
+ We have preview repositories for RPMs too, use them if you want to try
77
+ the latest version of libcouchbase:
78
+
79
+ [couchbase]
80
+ name = Couchbase package repository
81
+ baseurl = http://packages.couchbase.com/preview/rpm/5.5/i386
82
+
83
+ [couchbase]
84
+ name = Couchbase package repository
85
+ baseurl = http://packages.couchbase.com/preview/rpm/5.5/x86_64
86
+
87
+ ### Windows
88
+
89
+ There are no additional dependencies for Windows systems. The gem carries
90
+ a prebuilt binary for it.
91
+
92
+ ### Couchbase gem
93
+
94
+ Now install the couchbase gem itself
95
+
96
+ $ gem install couchbase
97
+
98
+ ## USAGE
99
+
100
+ First, you need to load the library:
101
+
102
+ require 'couchbase'
103
+
104
+ There are several ways to establish a new connection to Couchbase Server.
105
+ By default it uses `http://localhost:8091/pools/default/buckets/default`
106
+ as the endpoint. The client will automatically adjust configuration when
107
+ the cluster will rebalance its nodes when nodes are added or deleted
108
+ therefore this client is "smart".
109
+
110
+ c = Couchbase.connect
111
+
112
+ This is equivalent to following forms:
113
+
114
+ c = Couchbase.connect("http://localhost:8091/pools/default/buckets/default")
115
+ c = Couchbase.connect("http://localhost:8091/pools/default")
116
+ c = Couchbase.connect("http://localhost:8091")
117
+ c = Couchbase.connect(:hostname => "localhost")
118
+ c = Couchbase.connect(:hostname => "localhost", :port => 8091)
119
+ c = Couchbase.connect(:pool => "default", :bucket => "default")
120
+
121
+ The hash parameters take precedence on string URL.
122
+
123
+ If you worry about state of your nodes or not sure what node is alive,
124
+ you can pass the list of nodes and the library will iterate over it
125
+ until finds the working one. From that moment it won't use **your**
126
+ list, because node list from cluster config carries more detail.
127
+
128
+ c = Couchbase.connect(:bucket => "mybucket",
129
+ :node_list => ['example.com:8091', example.net'])
130
+
131
+ There is also a handy method `Couchbase.bucket` which uses thread local
132
+ storage to keep a reference to a connection. You can set the
133
+ connection options via `Couchbase.connection_options`:
134
+
135
+ Couchbase.connection_options = {:bucket => 'blog'}
136
+ Couchbase.bucket.name #=> "blog"
137
+ Couchbase.bucket.set("foo", "bar") #=> 3289400178357895424
138
+
139
+ The library supports both synchronous and asynchronous mode. In
140
+ asynchronous mode all operations will return control to caller
141
+ without blocking current thread. You can pass a block to the method and it
142
+ will be called with result when the operation will be completed. You
143
+ need to run the event loop once you've scheduled your operations:
144
+
145
+ c = Couchbase.connect
146
+ c.run do |conn|
147
+ conn.get("foo") {|ret| puts ret.value}
148
+ conn.set("bar", "baz")
149
+ end
150
+
151
+ The handlers could be nested
152
+
153
+ c.run do |conn|
154
+ conn.get("foo") do |ret|
155
+ conn.incr(ret.value, :initial => 0)
156
+ end
157
+ end
158
+
159
+ The asynchronous callback receives an instance of `Couchbase::Result` which
160
+ responds to several methods to figure out what was happened:
161
+
162
+ * `success?`. Returns `true` if operation succed.
163
+
164
+ * `error`. Returns `nil` or exception object (subclass of
165
+ `Couchbase::Error::Base`) if something went wrong.
166
+
167
+ * `key`
168
+
169
+ * `value`
170
+
171
+ * `flags`
172
+
173
+ * `cas`. The CAS version tag.
174
+
175
+ * `node`. Node address. This is used in the flush and stats commands.
176
+
177
+ * `operation`. The symbol, representing an operation.
178
+
179
+
180
+ To handle global errors in async mode `#on_error` callback should be
181
+ used. It can be set in following fashions:
182
+
183
+ c.on_error do |opcode, key, exc|
184
+ # ...
185
+ end
186
+
187
+ handler = lambda {|opcode, key, exc| }
188
+ c.on_error = handler
189
+
190
+ By default connections use `:quiet` mode. This mean it won't raise
191
+ exceptions when the given key does not exist:
192
+
193
+ c.get("missing-key") #=> nil
194
+
195
+ It could be useful when you are trying to make you code a bit efficient
196
+ by avoiding exception handling. (See `#add` and `#replace` operations).
197
+ You can turn on these exceptions by passing `:quiet => false` when you
198
+ are instantiating the connection or change corresponding attribute:
199
+
200
+ c.quiet = false
201
+ c.get("missing-key") #=> raise Couchbase::Error::NotFound
202
+ c.get("missing-key", :quiet => true) #=> nil
203
+
204
+ The library supports three different formats for representing values:
205
+
206
+ * `:document` (default) format supports most of ruby types which could
207
+ be mapped to JSON data (hashes, arrays, string, numbers). A future
208
+ version will be able to run map/reduce queries on the values in the
209
+ document form (hashes)
210
+
211
+ * `:plain` This format avoids any conversions to be applied to your
212
+ data, but your data should be passed as String. This is useful for
213
+ building custom algorithms or formats. For example to implement a set:
214
+ http://dustin.github.com/2011/02/17/memcached-set.html
215
+
216
+ * `:marshal` Use this format if you'd like to transparently serialize your
217
+ ruby object with standard `Marshal.dump` and `Marshal.load` methods
218
+
219
+ The couchbase API is the superset of [Memcached binary protocol][5], so
220
+ you can use its operations.
221
+
222
+ ### Get
223
+
224
+ val = c.get("foo")
225
+ val, flags, cas = c.get("foo", :extended => true)
226
+
227
+ Get and touch
228
+
229
+ val = c.get("foo", :ttl => 10)
230
+
231
+ Get multiple values. In quiet mode will put `nil` values on missing
232
+ positions:
233
+
234
+ vals = c.get("foo", "bar", "baz")
235
+ val_foo, val_bar, val_baz = c.get("foo", "bar", "baz")
236
+ c.run do
237
+ c.get("foo") do |ret|
238
+ ret.success?
239
+ ret.error
240
+ ret.key
241
+ ret.value
242
+ ret.flags
243
+ ret.cas
244
+ end
245
+ end
246
+
247
+ Get multiple values with extended information. The result will
248
+ represented by hash with tuples `[value, flags, cas]` as a value.
249
+
250
+ vals = c.get("foo", "bar", "baz", :extended => true)
251
+ vals.inspect #=> {"baz"=>["3", 0, 4784582192793125888],
252
+ "foo"=>["1", 0, 8835713818674332672],
253
+ "bar"=>["2", 0, 10805929834096100352]}
254
+
255
+ Hash-like syntax
256
+
257
+ c["foo"]
258
+ c["foo", "bar", "baz"]
259
+ c["foo", {:extended => true}]
260
+ c["foo", :extended => true] # for ruby 1.9.x only
261
+
262
+ ### Touch
263
+
264
+ c.touch("foo") # use :default_ttl
265
+ c.touch("foo", 10)
266
+ c.touch("foo", :ttl => 10)
267
+ c.touch("foo" => 10, "bar" => 20)
268
+ c.touch("foo" => 10, "bar" => 20){|key, success| }
269
+
270
+ ### Set
271
+
272
+ c.set("foo", "bar")
273
+ c.set("foo", "bar", :flags => 0x1000, :ttl => 30, :format => :plain)
274
+ c["foo"] = "bar"
275
+ c["foo", {:flags => 0x1000, :format => :plain}] = "bar"
276
+ c["foo", :flags => 0x1000] = "bar" # for ruby 1.9.x only
277
+ c.set("foo", "bar", :cas => 8835713818674332672)
278
+ c.set("foo", "bar"){|cas, key, operation| }
279
+
280
+ ### Add
281
+
282
+ The add command will fail if the key already exists. It accepts the same
283
+ options as set command above.
284
+
285
+ c.add("foo", "bar")
286
+ c.add("foo", "bar", :flags => 0x1000, :ttl => 30, :format => :plain)
287
+
288
+ ### Replace
289
+
290
+ The replace command will fail if the key already exists. It accepts the same
291
+ options as set command above.
292
+
293
+ c.replace("foo", "bar")
294
+
295
+ ### Prepend/Append
296
+
297
+ These commands are meaningful when you are using the `:plain` value format,
298
+ because the concatenation is performed by server which has no idea how
299
+ to merge to JSON values or values in ruby Marshal format. You may receive
300
+ an `Couchbase::Error::ValueFormat` error.
301
+
302
+ c.set("foo", "world")
303
+ c.append("foo", "!")
304
+ c.prepend("foo", "Hello, ")
305
+ c.get("foo") #=> "Hello, world!"
306
+
307
+ ### Increment/Decrement
308
+
309
+ These commands increment the value assigned to the key. It will raise
310
+ Couchbase::Error::DeltaBadval if the delta or value is not a number.
311
+
312
+ c.set("foo", 1)
313
+ c.incr("foo") #=> 2
314
+ c.incr("foo", :delta => 2) #=> 4
315
+ c.incr("foo", 4) #=> 8
316
+ c.incr("foo", -1) #=> 7
317
+ c.incr("foo", -100) #=> 0
318
+ c.run do
319
+ c.incr("foo") do |ret|
320
+ ret.success?
321
+ ret.value
322
+ ret.cas
323
+ end
324
+ end
325
+
326
+ c.set("foo", 10)
327
+ c.decr("foo", 1) #=> 9
328
+ c.decr("foo", 100) #=> 0
329
+ c.run do
330
+ c.decr("foo") do |ret|
331
+ ret.success?
332
+ ret.value
333
+ ret.cas
334
+ end
335
+ end
336
+
337
+ c.incr("missing1", :initial => 10) #=> 10
338
+ c.incr("missing1", :initial => 10) #=> 11
339
+ c.incr("missing2", :create => true) #=> 0
340
+ c.incr("missing2", :create => true) #=> 1
341
+
342
+ Note that it isn't the same as increment/decrement in ruby. A
343
+ Couchbase increment is atomic on a distributed system. The
344
+ Ruby incement could ovewrite intermediate values with multiple
345
+ clients, as shown with following `set` operation:
346
+
347
+ c["foo"] = 10
348
+ c["foo"] -= 20 #=> -10
349
+
350
+ ### Delete
351
+
352
+ c.delete("foo")
353
+ c.delete("foo", :cas => 8835713818674332672)
354
+ c.delete("foo", 8835713818674332672)
355
+ c.run do
356
+ c.delete do |ret|
357
+ ret.success?
358
+ ret.key
359
+ end
360
+ end
361
+
362
+ ### Flush
363
+
364
+ Flush the items in the cluster.
365
+
366
+ c.flush
367
+ c.run do
368
+ c.flush do |ret|
369
+ ret.success?
370
+ ret.node
371
+ end
372
+ end
373
+
374
+ ### Stats
375
+
376
+ Return statistics from each node in the cluster
377
+
378
+ c.stats
379
+ c.stats(:memory)
380
+ c.run do
381
+ c.stats do |ret|
382
+ ret.success?
383
+ ret.node
384
+ ret.key
385
+ ret.value
386
+ end
387
+ end
388
+
389
+ The result is represented as a hash with the server node address as
390
+ the key and stats as key-value pairs.
391
+
392
+ {
393
+ "threads"=>
394
+ {
395
+ "172.16.16.76:12008"=>"4",
396
+ "172.16.16.76:12000"=>"4",
397
+ # ...
398
+ },
399
+ "connection_structures"=>
400
+ {
401
+ "172.16.16.76:12008"=>"22",
402
+ "172.16.16.76:12000"=>"447",
403
+ # ...
404
+ },
405
+ "ep_max_txn_size"=>
406
+ {
407
+ "172.16.16.76:12008"=>"1000",
408
+ "172.16.16.76:12000"=>"1000",
409
+ # ...
410
+ },
411
+ # ...
412
+ }
413
+
414
+ ### Timers
415
+
416
+ It is possible to create timers to implement general purpose timeouts.
417
+ Note that timers are using microseconds for time intervals. For example,
418
+ following examples increment the keys value five times with 0.5 second
419
+ interval:
420
+
421
+ c.set("foo", 100)
422
+ n = 1
423
+ c.run do
424
+ c.create_periodic_timer(500000) do |tm|
425
+ c.incr("foo") do
426
+ if n == 5
427
+ tm.cancel
428
+ else
429
+ n += 1
430
+ end
431
+ end
432
+ end
433
+ end
434
+
435
+ ### Views (Map/Reduce queries)
436
+
437
+ If you store structured data, they will be treated as documents and you
438
+ can handle them in map/reduce function from Couchbase Views. For example,
439
+ store a couple of posts using memcached API:
440
+
441
+ c['biking'] = {:title => 'Biking',
442
+ :body => 'My biggest hobby is mountainbiking. The other day...',
443
+ :date => '2009/01/30 18:04:11'}
444
+ c['bought-a-cat'] = {:title => 'Bought a Cat',
445
+ :body => 'I went to the the pet store earlier and brought home a little kitty...',
446
+ :date => '2009/01/30 20:04:11'}
447
+ c['hello-world'] = {:title => 'Hello World',
448
+ :body => 'Well hello and welcome to my new blog...',
449
+ :date => '2009/01/15 15:52:20'}
450
+
451
+ Now let's create design doc with sample view and save it in file
452
+ 'blog.json':
453
+
454
+ {
455
+ "_id": "_design/blog",
456
+ "language": "javascript",
457
+ "views": {
458
+ "recent_posts": {
459
+ "map": "function(doc){if(doc.date && doc.title){emit(doc.date, doc.title);}}"
460
+ }
461
+ }
462
+ }
463
+
464
+ This design document could be loaded into the database like this (also you can
465
+ pass the ruby Hash or String with JSON encoded document):
466
+
467
+ c.save_design_doc(File.open('blog.json'))
468
+
469
+ To execute view you need to fetch it from design document `_design/blog`:
470
+
471
+ blog = c.design_docs['blog']
472
+ blog.views #=> ["recent_posts"]
473
+ blog.recent_posts #=> [#<Couchbase::ViewRow:9855800 @id="hello-world" @key="2009/01/15 15:52:20" @value="Hello World" @doc=nil @meta={} @views=[]>, ...]
474
+
475
+ The gem uses a streaming parser to access view results so you can iterate them
476
+ easily. If your code doesn't keep links to the documents the GC might free
477
+ them as soon as it decides they are unreachable, because the parser doesn't
478
+ store global JSON tree.
479
+
480
+ blog.recent_posts.each do |doc|
481
+ # do something
482
+ # with doc object
483
+ doc.key # gives the key argument of the emit()
484
+ doc.value # gives the value argument of the emit()
485
+ end
486
+
487
+ Load with documents
488
+
489
+ blog.recent_posts(:include_docs => true).each do |doc|
490
+ doc.doc # gives the document which emitted the item
491
+ doc['date'] # gives the argument of the underlying document
492
+ end
493
+
494
+
495
+ You can also use Enumerator to iterate view results
496
+
497
+ require 'date'
498
+ posts_by_date = Hash.new{|h,k| h[k] = []}
499
+ enum = c.recent_posts(:include_docs => true).each # request hasn't issued yet
500
+ enum.inject(posts_by_date) do |acc, doc|
501
+ acc[date] = Date.strptime(doc['date'], '%Y/%m/%d')
502
+ acc
503
+ end
504
+
505
+ Couchbase Server could generate errors during view execution with
506
+ `200 OK` and partial results. By default the library raises exception as
507
+ soon as errors detected in the result stream, but you can define the
508
+ callback `on_error` to intercept these errors and do something more
509
+ useful.
510
+
511
+ view = blog.recent_posts(:include_docs => true)
512
+ logger = Logger.new(STDOUT)
513
+
514
+ view.on_error do |from, reason|
515
+ logger.warn("#{view.inspect} received the error '#{reason}' from #{from}")
516
+ end
517
+
518
+ posts = view.each do |doc|
519
+ # do something
520
+ # with doc object
521
+ end
522
+
523
+ Note that errors object in view results usually goes *after* the rows,
524
+ so you will likely receive a number of view results successfully before
525
+ the error is detected.
526
+
527
+ ## Engines
528
+
529
+ As far as couchbase gem uses [libcouchbase][8] as the backend, you can
530
+ choose from several asynchronous IO options:
531
+
532
+ * `:default` this one is used by default and implemented as the part
533
+ of the ruby extensions (this mean you don't need any dependencies
534
+ apart from libcouchbase2-core and libcouchbase-dev to build and use
535
+ it). This engine honours ruby GVL, so when it comes to waiting for
536
+ IO operations from kernel it release the GVL allowing interpreter to
537
+ run your code. This technique isn't available on windows, but down't
538
+ worry `:default` engine still accessible and will pick up statically
539
+ linked on that platform `:libevent` engine.
540
+
541
+ * `:libev` and `:libevent`, these two engines require installed
542
+ libcouchbase2-libev and libcouchbase2-libevent packages
543
+ correspondingly. Currently they aren't so friendly to GVL but still
544
+ useful.
545
+
546
+ * `:eventmachine` engine. From version 1.2.2 it is possible to use
547
+ great [EventMachine][9] library as underlying IO backend and
548
+ integrate couchbase gem to your current asynchronous application.
549
+ This engine will be only accessible on the MRI ruby 1.9+. Checkout
550
+ simple example of usage:
551
+
552
+ require 'eventmachine'
553
+ require 'couchbase'
554
+
555
+ EM.epoll = true if EM.epoll?
556
+ EM.kqueue = true if EM.kqueue?
557
+ EM.run do
558
+ con = Couchbase.connect :engine => :eventmachine, :async => true
559
+ con.on_connect do |res|
560
+ puts "connected: #{res.inspect}"
561
+ if res.success?
562
+ con.set("emfoo", "bar") do |res|
563
+ puts "set: #{res.inspect}"
564
+ con.get("emfoo") do |res|
565
+ puts "get: #{res.inspect}"
566
+ EM.stop
567
+ end
568
+ end
569
+ else
570
+ EM.stop
571
+ end
572
+ end
573
+ end
574
+
575
+ ## HACKING
576
+
577
+ Clone the repository. For starters, you can use github mirror, but
578
+ make sure you have read and understand [CONTRIBUTING.markdown][10] if
579
+ you are going to send us patches.
580
+
581
+ $ git clone git://github.com/couchbase/couchbase-ruby-client.git
582
+ $ cd couchbase-ruby-client
583
+
584
+ Install all development dependencies. You can use any ruby version
585
+ since 1.8.7, but make sure your changes work at least on major
586
+ releases (1.8.7, 1.9.3, 2.0.0 and 2.1.0 at the moment):
587
+
588
+ $ gem install bundler
589
+ $ bundle install
590
+
591
+ Don't forget to write the tests. You can find examples in the `tests/`
592
+ directory. To run tests with a mock just compile extension and run the
593
+ `test` task, it will download a test mock of couchbase cluster as a
594
+ part of the process (the mock is generally slower, but easier to
595
+ setup):
596
+
597
+ $ rake compile test
598
+
599
+ If you have real Couchbase server installed somewhere, you can pass
600
+ its address using environment variable `COUCHBASE_SERVER` like this:
601
+
602
+ $ COUCHBASE_SERVER=localhost:8091 rake compile test
603
+
604
+ And finally, you can package the gem with your awesome changes. For
605
+ UNIX-like systems a regular source-based package will be enough, so the
606
+ command below will produce `pkg/couchbase-VERSION.gem`, where
607
+ `VERSION` is the current version from file `lib/couchbase/version.rb`:
608
+
609
+ $ rake package
610
+
611
+ The Windows operating system usually doesn't have a build environment
612
+ installed. This is why we are cross-compiling blobs for Windows from
613
+ UNIX-like boxes. To do it you need to install mingw and the
614
+ [rake-compiler][11] and then build a variety of ruby versions currently
615
+ supported on Windows. An example config looks like this:
616
+
617
+ $ rake-compiler update-config
618
+ Updating /home/avsej/.rake-compiler/config.yml
619
+ Found Ruby version 1.8.7 for platform i386-mingw32 (/home/avsej/.rake-compiler/ruby/i686-w64-mingw32/ruby-1.8.7-p374/lib/ruby/1.8/i386-mingw32/rbconfig.rb)
620
+ Found Ruby version 1.9.3 for platform i386-mingw32 (/home/avsej/.rake-compiler/ruby/i686-w64-mingw32/ruby-1.9.3-p448/lib/ruby/1.9.1/i386-mingw32/rbconfig.rb)
621
+ Found Ruby version 2.0.0 for platform i386-mingw32 (/home/avsej/.rake-compiler/ruby/i686-w64-mingw32/ruby-2.0.0-p247/lib/ruby/2.0.0/i386-mingw32/rbconfig.rb)
622
+ Found Ruby version 2.1.0 for platform i386-mingw32 (/home/avsej/.rake-compiler/ruby/i686-w64-mingw32/ruby-2.1.0/lib/ruby/2.1.0/i386-mingw32/rbconfig.rb)
623
+ Found Ruby version 1.9.3 for platform x64-mingw32 (/home/avsej/.rake-compiler/ruby/x86_64-w64-mingw32/ruby-1.9.3-p448/lib/ruby/1.9.1/x64-mingw32/rbconfig.rb)
624
+ Found Ruby version 2.0.0 for platform x64-mingw32 (/home/avsej/.rake-compiler/ruby/x86_64-w64-mingw32/ruby-2.0.0-p247/lib/ruby/2.0.0/x64-mingw32/rbconfig.rb)
625
+ Found Ruby version 2.1.0 for platform x64-mingw32 (/home/avsej/.rake-compiler/ruby/x86_64-w64-mingw32/ruby-2.1.0/lib/ruby/2.1.0/x64-mingw32/rbconfig.rb)
626
+
627
+ Before you build, check relevant ruby and libcouchbase versions in
628
+ `tasks/compile.rake`. After that you can run the `package:windows`
629
+ task and you will find all artifacts in `pkg/` directory:
630
+
631
+ $ rake package:windows
632
+ $ ls -1 pkg/*.gem
633
+ pkg/couchbase-1.3.4.gem
634
+ pkg/couchbase-1.3.4-x64-mingw32.gem
635
+ pkg/couchbase-1.3.4-x86-mingw32.gem
636
+
637
+
638
+ [1]: http://couchbase.com/issues/browse/RCBC
639
+ [2]: http://freenode.net/irc_servers.shtml
640
+ [3]: http://www.couchbase.com/develop/c/current
641
+ [4]: https://github.com/mxcl/homebrew/pulls/avsej
642
+ [5]: http://code.google.com/p/memcached/wiki/BinaryProtocolRevamped
643
+ [6]: https://rubygems.org/gems/couchbase-model
644
+ [7]: https://github.com/couchbase/couchbase-ruby-model
645
+ [8]: http://www.couchbase.com/develop/c/current
646
+ [9]: http://rubygems.org/gems/eventmachine
647
+ [10]: https://github.com/couchbase/couchbase-ruby-client/blob/master/CONTRIBUTING.markdown
648
+ [11]: https://github.com/luislavena/rake-compiler
649
+