module CryBase::CouchBase::Services::KV

Overview

Implementation of the Couchbase KV (Data) service over Couchbase's memcached binary protocol, using plaintext or TLS sockets according to the endpoint or connection string.

The main public entry points are KV::Client.from_string for one authenticated connection, KV::Pool.from_string for a fixed-size pool, and KV::Cluster.from_string for seed failover across multiple KV hosts. They accept connection strings with credentials, bucket, explicit KV port, and TLS query options:

cluster = CryBase::CouchBase::KV::Cluster.from_string(
  "couchbases://user:pass@node1,node2:11217/default?tls_verify=false"
)
cluster.set("hello", "world")
cluster.get("hello") # => Bytes containing "world"
cluster.close

You can still construct an Endpoint explicitly or through CryBase::CouchBase::Endpoint.from_string and pass it to KV::Client.new or KV::Pool.new when credentials and bucket should stay separate from the endpoint address.

The namespace is structured as small composable pieces:

KV::Client composes the request/response/bucket mixins, performs HELLO, SASL_AUTH(PLAIN), and SELECT_BUCKET, then exposes document, expiry, counter, and typed JSON helper operations.

Defined in:

crybase/couchbase/services/kv.cr
crybase/couchbase/services/kv/auth_failed.cr
crybase/couchbase/services/kv/bucket.cr
crybase/couchbase/services/kv/client.cr
crybase/couchbase/services/kv/cluster.cr
crybase/couchbase/services/kv/counter.cr
crybase/couchbase/services/kv/error.cr
crybase/couchbase/services/kv/expiry.cr
crybase/couchbase/services/kv/not_found.cr
crybase/couchbase/services/kv/opcode.cr
crybase/couchbase/services/kv/pool.cr
crybase/couchbase/services/kv/request.cr
crybase/couchbase/services/kv/request_buffer.cr
crybase/couchbase/services/kv/request_writer.cr
crybase/couchbase/services/kv/response.cr
crybase/couchbase/services/kv/response_reader.cr
crybase/couchbase/services/kv/serializable.cr
crybase/couchbase/services/kv/status.cr
crybase/couchbase/services/kv/vbucket.cr

Class Method Summary

Class Method Detail

def self.counter_extras(delta : UInt64, initial : UInt64, expiry : UInt32) : Bytes #

[View source]
def self.counter_value(value : Bytes) : UInt64 #

[View source]
def self.expiry_extras(expiry : UInt32) : Bytes #

[View source]
def self.vbucket_id(key : String, count : UInt16 = Constants::VBUCKET_COUNT) : UInt16 #

[View source]