Module: Couchbase

Defined in:
lib/couchbase.rb,
lib/couchbase/bucket.rb,
lib/couchbase/version.rb,
ext/couchbase_ext/couchbase_ext.c

Overview

Couchbase ruby client

Defined Under Namespace

Modules: Error Classes: Bucket, Result

Constant Summary collapse

VERSION =
"1.1.4"

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)


55
56
57
# File 'lib/couchbase.rb', line 55

def connection_options
  @connection_options
end

Class Method Details

.bucketBucket

The connection instance for current thread

Examples:

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

Returns:



68
69
70
# File 'lib/couchbase.rb', line 68

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

.bucket=(connection) ⇒ Bucket

Set a connection instance for current thread

Returns:



75
76
77
# File 'lib/couchbase.rb', line 75

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')

Returns:

  • (Bucket)

    connection instance



43
44
45
# File 'lib/couchbase.rb', line 43

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