Class Bucket

java.lang.Object
com.couchbase.client.java.Bucket

public class Bucket extends Object
Provides access to a Couchbase bucket in a blocking fashion.
  • Method Details Link icon

    • async Link icon

      public AsyncBucket async()
      Provides access to the underlying AsyncBucket.
    • reactive Link icon

      public ReactiveBucket reactive()
      Provides access to the related ReactiveBucket.
    • name Link icon

      public String name()
      Returns the name of the Bucket.
    • environment Link icon

      public ClusterEnvironment environment()
      Returns the attached ClusterEnvironment.
    • collections Link icon

      public CollectionManager collections()
    • viewIndexes Link icon

      public ViewIndexManager viewIndexes()
    • core Link icon

      @Volatile public Core core()
      Provides access to the underlying Core.

      This is advanced API, use with care!

    • scope Link icon

      public Scope scope(String name)
      Opens the Scope with the given name.
      Parameters:
      name - the name of the scope.
      Returns:
      the Scope once opened.
    • defaultScope Link icon

      public Scope defaultScope()
      Opens the default Scope.
      Returns:
      the Scope once opened.
    • defaultCollection Link icon

      public Collection defaultCollection()
      Opens the default collection for this Bucket using the default scope.

      This method does not block and the client will try to establish all needed resources in the background. If you need to eagerly await until all resources are established before performing an operation, use the waitUntilReady(Duration) method on the Bucket.

      Returns:
      the opened default Collection.
    • collection Link icon

      public Collection collection(String collectionName)
      Provides access to the collection with the given name for this Bucket using the default scope.

      This method does not block and the client will try to establish all needed resources in the background. If you need to eagerly await until all resources are established before performing an operation, use the waitUntilReady(Duration) method on the Bucket.

      Returns:
      the opened named Collection.
    • viewQuery Link icon

      public ViewResult viewQuery(String designDoc, String viewName)
      Queries a view on the bucket.
      Parameters:
      designDoc - the name of the design document in which the view resides.
      viewName - the name of the view to query.
      Returns:
      a ViewResult once completed.
      Throws:
      ViewNotFoundException - if the view or design document is not found on the server.
      TimeoutException - if the operation times out before getting a result.
      CouchbaseException - for all other error reasons (acts as a base type and catch-all).
    • viewQuery Link icon

      public ViewResult viewQuery(String designDoc, String viewName, ViewOptions options)
      Queries a view on the bucket with custom options.
      Parameters:
      designDoc - the name of the design document in which the view resides.
      viewName - the name of the view to query.
      options - allows to customize view options.
      Returns:
      a ViewResult once completed.
      Throws:
      ViewNotFoundException - if the view or design document is not found on the server.
      TimeoutException - if the operation times out before getting a result.
      CouchbaseException - for all other error reasons (acts as a base type and catch-all).
    • ping Link icon

      public PingResult ping()
      Performs application-level ping requests against services in the couchbase cluster.
      Returns:
      the PingResult once complete.
    • ping Link icon

      public PingResult ping(PingOptions options)
      Performs application-level ping requests with custom options against services in the couchbase cluster.
      Returns:
      the PingResult once complete.
    • waitUntilReady Link icon

      public void waitUntilReady(Duration timeout)
      Waits until the desired ClusterState is reached.

      This method will wait until either the cluster state is "online", or the timeout is reached. Since the SDK is bootstrapping lazily, this method allows to eagerly check during bootstrap if all of the services are online and usable before moving on.

      Parameters:
      timeout - the maximum time to wait until readiness.
    • waitUntilReady Link icon

      public void waitUntilReady(Duration timeout, WaitUntilReadyOptions options)
      Waits until the desired ClusterState is reached.

      This method will wait until either the cluster state is "online" by default, or the timeout is reached. Since the SDK is bootstrapping lazily, this method allows to eagerly check during bootstrap if all of the services are online and usable before moving on. You can tune the properties through WaitUntilReadyOptions.

      Parameters:
      timeout - the maximum time to wait until readiness.
      options - the options to customize the readiness waiting.