Couchbase Transactions C++ Client  1.0.0
Transactions client for couchbase
Public Member Functions | Friends | List of all members
couchbase::bucket Class Reference

Exposes bucket-level operations and collections accessors. More...

#include <bucket.hxx>

Inheritance diagram for couchbase::bucket:

Public Member Functions

CB_NODISCARD std::shared_ptr< class collectiondefault_collection ()
 
CB_NODISCARD std::shared_ptr< class collectioncollection (const std::string &name)
 Get a collection by name. More...
 
CB_NODISCARD const std::string & name () const
 Get collection name. More...
 
void close ()
 Close connection to this bucket. More...
 
 ~bucket ()
 Destroy the bucket. More...
 
CB_NODISCARD size_t max_instances () const
 return maximum number of libcouchbase instances this bucket can use More...
 
CB_NODISCARD size_t instances () const
 return current number of libcouchbase instances the cluster has created. More...
 
CB_NODISCARD size_t available_instances () const
 return the current number of libcouchbase instances that are not being used. More...
 
CB_NODISCARD std::chrono::microseconds default_kv_timeout () const
 return default kv timeout More...
 
CB_NODISCARD bool operator== (const bucket &b) const
 

Friends

class collection
 
class cluster
 
template<typename OStream >
OStream & operator<< (OStream &os, const bucket &b)
 convienence method to allow outputtng information about the bucket to an ostream or similar.
 

Detailed Description

Exposes bucket-level operations and collections accessors.

Examples:
examples/game_server.cxx.

Constructor & Destructor Documentation

◆ ~bucket()

couchbase::bucket::~bucket ( )

Destroy the bucket.

Calls close(), which disconnects the bucket from the cluster, then destroys the object.

Member Function Documentation

◆ available_instances()

CB_NODISCARD size_t couchbase::bucket::available_instances ( ) const

return the current number of libcouchbase instances that are not being used.

Returns
current available instances.

◆ close()

void couchbase::bucket::close ( )

Close connection to this bucket.

Once you call this, this object will no longer be connected to the cluster. This means any collection objects created from this bucket (all of whom share this connection) will also not be connected. Called in destructor, but here in case you one needs it

◆ collection()

CB_NODISCARD std::shared_ptr<class collection> couchbase::bucket::collection ( const std::string &  name)

Get a collection by name.

Parameters
nameof an existing collection in this bucket.
Returns
shared pointer to a the collection.

◆ default_collection()

CB_NODISCARD std::shared_ptr<class collection> couchbase::bucket::default_collection ( )

Get the default collection for this bucket

Returns
Returns a shared pointer to the default collection for this bucket.
Examples:
examples/game_server.cxx.

◆ default_kv_timeout()

CB_NODISCARD std::chrono::microseconds couchbase::bucket::default_kv_timeout ( ) const

return default kv timeout

Returns
The default kv timeout.
See also
cluster_options::kv_timeout for setting this, and
common_options::timeout to use a different timeout on an operation.

◆ instances()

CB_NODISCARD size_t couchbase::bucket::instances ( ) const

return current number of libcouchbase instances the cluster has created.

Returns
total number of instances the cluster is maintaining.

◆ max_instances()

CB_NODISCARD size_t couchbase::bucket::max_instances ( ) const

return maximum number of libcouchbase instances this bucket can use

The bucket maintains a pool of instances, lazily created, which it uses to communicate with the server. Each instance will maintain a number of socket connections. Any cluster calls that need an instance will use one, making it unavailable until the call is done with it. See cluster_options to set this value, which the cluster uses when it creates the bucket.

Returns
maximum number of libcouchbase instances the cluster can use.

◆ name()

CB_NODISCARD const std::string& couchbase::bucket::name ( ) const
inline

Get collection name.

Return the collection name.

Returns
constant string containing this collection's name. Note the default collection is _default.

The documentation for this class was generated from the following file: