本文整理汇总了Golang中github.com/aerospike/aerospike-client-go.Client.BatchGetHeader方法的典型用法代码示例。如果您正苦于以下问题:Golang Client.BatchGetHeader方法的具体用法?Golang Client.BatchGetHeader怎么用?Golang Client.BatchGetHeader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/aerospike/aerospike-client-go.Client
的用法示例。
在下文中一共展示了Client.BatchGetHeader方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: batchReadHeaders
/**
* Read record header data in one batch.
*/
func batchReadHeaders(
client *as.Client,
keyPrefix string,
size int,
) {
// Batch gets into one call.
keys := make([]*as.Key, size)
for i := 0; i < size; i++ {
keys[i], _ = as.NewKey(*shared.Namespace, *shared.Set, keyPrefix+strconv.Itoa(i+1))
}
records, err := client.BatchGetHeader(nil, keys)
shared.PanicOnError(err)
for i := 0; i < len(records); i++ {
key := keys[i]
record := records[i]
level := asl.ERR
generation := 0
expiration := 0
if record != nil && (record.Generation > 0 || record.Expiration > 0) {
level = asl.INFO
generation = record.Generation
expiration = record.Expiration
}
asl.Logger.LogAtLevel(level, "Record: ns=%s set=%s key=%s generation=%d expiration=%d",
key.Namespace(), key.SetName(), key.Value(), generation, expiration)
}
if len(records) != size {
log.Fatalf("Record size mismatch. Expected %d. Received %d.", size, len(records))
}
}