假设在我的 LDT(LargeMap) Bin 我有以下值,
key1, value1
key2, value2
key3, value3
key4, value4
. .
key50, value50
现在,我使用以下代码段获取所需的数据:
Map<?, ?> myFinalRecord = new HashMap<?, ?>();
// First call to client to get the largeMap associated with the bin
LargeMap largeMap = myDemoClient.getLargeMap(myPolicy, myKey, myLDTBinName, null);
for (String myLDTKey : myRequiredKeysFromLDTBin) {
try {
// Here each get call results in one call to aerospike
myFinalRecord.putAll(largeMap.get(Value.get(myLDTKey)));
} catch (Exception e) {
log.warn("Key does not exist in LDT Bin");
}
}
如果myRequiredKeysFromLDTBin
包含 20 个键,问题就在这里。然后largeMap.get(Value.get(myLDTKey))
将向 aerospike 拨打 20 次电话。
因此,如果我每笔交易的检索时间为 1 毫秒,那么我从记录中检索 20 个 id 的一次调用将导致对 aerospike 的 20 次调用。这会将我的响应时间增加到大约。20 毫秒!
那么有什么方法可以让我传递一组要从 LDT Bin 中检索的 id 并且只需要一个调用就可以做到这一点?