A newer version of this documentation is available.

View Latest

Buckets and Clusters

  • concept
    +
    The Couchbase Ruby SDK provides an API for managing a Couchbase cluster programmatically.

    The primary means for managing clusters is through the Couchbase Web UI which provides an easy to use interface for adding, removing, monitoring, and modifying buckets. In some instances you may wish to have a programmatic interface. For example, if you wish to manage a cluster from a setup script, or if you are setting up buckets in test scaffolding.

    The SDK also comes with some convenience functionality for common Couchbase management requests — see the Provisioning Cluster Resources guide.

    Management operations in the Ruby SDK may be performed through several interfaces depending on the object:

    Creating and Removing Buckets

    To create or delete a bucket, call the bucket manager with the buckets call on the cluster:

    options = Cluster::ClusterOptions.new
    options.authenticate("Administrator", "password")
    cluster = Cluster.connect("couchbase://localhost", options)
    
    manager = cluster.buckets
    
    settings = Management::BucketSettings.new
    settings.name = "travel-sample"
    settings.ram_quota_mb = 100
    settings.flush_enabled = true
    manager.create_bucket(settings)

    This class is also used to expose information about an existing bucket (manager.get_bucket(String)) or to update an existing bucket (manager.update_bucket(bucket_settings)).

    The default Collection & Default Scope will be used automatically.