CouchbaseBackend
Couchbase backend.
Attributes
| Attribute | Type | Description |
|---|---|---|
| bucket | string = default | The name of the Couchbase bucket used for data storage. |
| host | string = localhost | The hostname or IP address of the Couchbase server node. |
| port | integer = 8091 | The network port number used to connect to the Couchbase cluster. |
| username | string = null | The username used for authenticating with the Couchbase cluster. |
| password | string = null | The password used for authenticating with the Couchbase cluster. |
| quiet | boolean = false | Flag to determine if connection errors should be suppressed. |
| supports_autoexpire | boolean = true | Indicates that the backend supports automatic expiration of keys via TTL. |
| timeout | float = 2.5 | The maximum time in seconds to wait for Couchbase operations to complete. |
| key_t | type = str | Use str as couchbase key not bytes |
Constructor
Signature
def CouchbaseBackend(
url: string = None,
*args: any,
**kwargs: any
)
Parameters
| Name | Type | Description |
|---|---|---|
| url | string = None | The connection URL containing Couchbase server details. |
| *args | any | Variable length argument list passed to the parent class. |
| **kwargs | any | Arbitrary keyword arguments passed to the parent class. |
Methods
connection()
@classmethod
def connection() - > couchbase.collection.Collection
Provides access to the active Couchbase connection, initializing it if it does not already exist.
Returns
| Type | Description |
|---|---|
couchbase.collection.Collection | The active Couchbase collection used for data operations |
get()
@classmethod
def get(
key: str
) - > Any
Retrieves the content associated with a specific key from the Couchbase bucket.
Parameters
| Name | Type | Description |
|---|---|---|
| key | str | The unique identifier for the document to retrieve |
Returns
| Type | Description |
|---|---|
Any | The deserialized content stored under the provided key |
set()
@classmethod
def set(
key: str,
value: Any
)
Stores or updates a value in the Couchbase bucket using an upsert operation with an optional expiration time.
Parameters
| Name | Type | Description |
|---|---|---|
| key | str | The unique identifier under which the value will be stored |
| value | Any | The data to be stored, which must be compatible with Couchbase JSON serialization |
mget()
@classmethod
def mget(
keys: list
) - > dict
Fetches multiple documents from the Couchbase bucket in a single batch operation.
Parameters
| Name | Type | Description |
|---|---|---|
| keys | list | A list of unique identifiers for the documents to be retrieved |
Returns
| Type | Description |
|---|---|
dict | A dictionary mapping the requested keys to their corresponding document results |
delete()
@classmethod
def delete(
key: str
)
Removes a document from the Couchbase bucket based on the provided key.
Parameters
| Name | Type | Description |
|---|---|---|
| key | str | The unique identifier of the document to be deleted |