Module: Couchbase

Defined in:
lib/couchbase.rb,
lib/couchbase/view.rb,
lib/couchbase/utils.rb,
lib/couchbase/bucket.rb,
lib/couchbase/result.rb,
lib/couchbase/cluster.rb,
lib/couchbase/version.rb,
lib/couchbase/view_row.rb,
lib/couchbase/constants.rb,
ext/couchbase_ext/couchbase_ext.c

Overview

Author

Couchbase <[email protected]>

Copyright

2011-2012 Couchbase, Inc.

License

Apache License, Version 2.0

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Defined Under Namespace

Modules: Constants, EM, Error Classes: Bucket, Cluster, DesignDoc, Result, Timer, Utils, View, ViewRow

Constant Summary collapse

VERSION =
"1.2.2"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.connection_optionsHash, String

Default connection options

Examples:

Using connection_options to change the bucket

Couchbase.connection_options = {:bucket => 'blog'}
Couchbase.bucket.name     #=> "blog"

Returns:

  • (Hash, String)

Since:

  • 1.1.0



72
73
74
# File 'lib/couchbase.rb', line 72

def connection_options
  @connection_options
end

Class Method Details

.bucketBucket

The connection instance for current thread

Examples:

Couchbase.bucket.set("foo", "bar")

Returns:

See Also:

Since:

  • 1.1.0



89
90
91
# File 'lib/couchbase.rb', line 89

def bucket
  thread_storage[:bucket] ||= connect(connection_options)
end

.bucket=(connection) ⇒ Bucket

Set a connection instance for current thread

Returns:

Since:

  • 1.1.0



98
99
100
# File 'lib/couchbase.rb', line 98

def bucket=(connection)
  thread_storage[:bucket] = connection
end

.connect(*options) ⇒ Bucket Also known as: new

The method connect initializes new Bucket instance with all arguments passed.

Examples:

Use default values for all options

Couchbase.connect

Establish connection with couchbase default pool and default bucket

Couchbase.connect("http://localhost:8091/pools/default")

Select custom bucket

Couchbase.connect("http://localhost:8091/pools/default", :bucket => 'blog')

Specify bucket credentials

Couchbase.connect("http://localhost:8091/pools/default", :bucket => 'blog', :username => 'bucket', :password => 'secret')

Use URL notation

Couchbase.connect("http://bucket:secret@localhost:8091/pools/default/buckets/blog")

Returns:

  • (Bucket)

    connection instance

See Also:

Since:

  • 1.0.0



58
59
60
# File 'lib/couchbase.rb', line 58

def connect(*options)
  Bucket.new(*(options.flatten))
end