当前位置: 首页>>代码示例>>C#>>正文


C# IAsyncDatabaseCommands.ForceReadFromMaster方法代码示例

本文整理汇总了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;
 }
开发者ID:heinnge,项目名称:ravendb,代码行数:10,代码来源:DocumentStore.cs

示例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
                }
            }
        }
开发者ID:j2jensen,项目名称:ravendb,代码行数:55,代码来源:AsyncHiLoKeyGenerator.cs


注:本文中的IAsyncDatabaseCommands.ForceReadFromMaster方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。