Hi,
I just upgrade to 3.2 sdk, and i found a weird behavior. Now you are mainly using exception to return value. I do understand that change. But exception, is quite heavy in term of performance and must be used in “Exception case”. I do think that in the case of Lookup and Exist: the fact that a document do not exist is a common case and not an exception.
I did a patch in a copy of the code from the git hub. By not throwing an exception in those case, and returning a GetResult null increase the performance of our real life code by 30%.
It will be amazing to have an options in the lookup to ask to not throw exception in case of key not found but instead a null result.
More the exist function will gain a lot also by not throwing the exception for catching it right after.
Best regards,
David.
My lazy test in the code:
Cluster Node:
if ((op.OpCode == OpCode.Get || op.OpCode == OpCode.MultiLookup) && status == ResponseStatus.KeyNotFound)
{
return;
}
else
{
throw status.CreateException(ctx, op);
}
And in the GetAsync in couchbase collection:
if (!lookupOp.GetSuccess())
{
return null;
}
return new GetResult(lookupOp.ExtractBody(), lookupOp.Transcoder, _getLogger, specs, projectList)
{
Id = lookupOp.Key,
Cas = lookupOp.Cas,
OpCode = lookupOp.OpCode,
Flags = lookupOp.Flags,
Header = lookupOp.Header,
Opaque = lookupOp.Opaque,
};
David.