本文整理汇总了C#中IAsyncDatabaseCommands.ForceReadFromMaster方法的典型用法代码示例。如果您正苦于以下问题:C# IAsyncDatabaseCommands.ForceReadFromMaster方法的具体用法?C# IAsyncDatabaseCommands.ForceReadFromMaster怎么用?C# IAsyncDatabaseCommands.ForceReadFromMaster使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IAsyncDatabaseCommands
的用法示例。
在下文中一共展示了IAsyncDatabaseCommands.ForceReadFromMaster方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetupCommandsAsync
private static IAsyncDatabaseCommands SetupCommandsAsync(IAsyncDatabaseCommands databaseCommands, string database, ICredentials credentialsForSession, OpenSessionOptions options)
{
if (database != null)
databaseCommands = databaseCommands.ForDatabase(database);
if (credentialsForSession != null)
databaseCommands = databaseCommands.With(credentialsForSession);
if (options.ForceReadFromMaster)
databaseCommands.ForceReadFromMaster();
return databaseCommands;
}
示例2: GetNextMaxAsyncInner
private async Task<RangeValue> GetNextMaxAsyncInner(IAsyncDatabaseCommands databaseCommands)
{
var minNextMax = Range.Max;
using (databaseCommands.ForceReadFromMaster())
while (true)
{
try
{
ConflictException ce = null;
JsonDocument document;
try
{
document = await GetDocumentAsync(databaseCommands).ConfigureAwait(false);
}
catch (ConflictException e)
{
ce = e;
document = null;
}
if (ce != null)
return await HandleConflictsAsync(databaseCommands, ce, minNextMax).ConfigureAwait(false);
long min, max;
if (document == null)
{
min = minNextMax + 1;
max = minNextMax + capacity;
document = new JsonDocument
{
Etag = Etag.Empty,
// sending empty etag means - ensure the that the document does NOT exists
Metadata = new RavenJObject(),
DataAsJson = RavenJObject.FromObject(new { Max = max }),
Key = HiLoDocumentKey
};
}
else
{
var oldMax = GetMaxFromDocument(document, minNextMax);
min = oldMax + 1;
max = oldMax + capacity;
document.DataAsJson["Max"] = max;
}
await PutDocumentAsync(databaseCommands, document).ConfigureAwait(false);
return new RangeValue(min, max);
}
catch (ConcurrencyException)
{
//expected & ignored, will retry this
}
}
}