getMultiReplicasFromPreferredServerGroup

Similar to getMulti, but fetches the documents from replicas in the preferred server group.

Note that the nature of replicas is that they are eventually consistent with the active, and so the effectiveness of read skew detection may be impacted.

Parameters

specs

specifies the documents to get

mode

level of effort to spend on minimizing read skew. The default is intentionally unspecified.

Samples

import com.couchbase.client.kotlin.Cluster
import com.couchbase.client.kotlin.Collection
import com.couchbase.client.kotlin.transactions.TransactionDocumentSpec
import com.couchbase.client.kotlin.transactions.TransactionGetMultiMode
import com.couchbase.client.kotlin.transactions.TransactionGetResult
import kotlin.random.Random

fun main() { 
   //sampleStart 
   // Get multiple documents at once, making great effort to avoid read skew.
cluster.transactions.run {
    val spec1 = TransactionDocumentSpec(collection, "someDocumentId")

    // Or use shorthand:
    val spec2 = collection + "anotherDocumentId"

    val result = getMulti(
        specs = listOf(spec1, spec2),
        mode = TransactionGetMultiMode.prioritizeReadSkewDetection(),
    )

    println(result.getOrNull(spec1)?.content)
    println(result.getOrNull(spec2)?.content)
} 
   //sampleEnd
}