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


C# IDatabaseCommands.ForceReadFromMaster方法代码示例

本文整理汇总了C#中IDatabaseCommands.ForceReadFromMaster方法的典型用法代码示例。如果您正苦于以下问题:C# IDatabaseCommands.ForceReadFromMaster方法的具体用法?C# IDatabaseCommands.ForceReadFromMaster怎么用?C# IDatabaseCommands.ForceReadFromMaster使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IDatabaseCommands的用法示例。


在下文中一共展示了IDatabaseCommands.ForceReadFromMaster方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetupCommands

 private static IDatabaseCommands SetupCommands(IDatabaseCommands 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: GetNextRange

		private RangeValue GetNextRange(IDatabaseCommands databaseCommands)
		{
			using (new TransactionScope(TransactionScopeOption.Suppress))
			using (RavenTransactionAccessor.SupressExplicitRavenTransaction())
			using (databaseCommands.ForceReadFromMaster())
			{
				ModifyCapacityIfRequired();
				while (true)
				{
					try
					{
						var minNextMax = Range.Max;
						JsonDocument document;

						try
						{
							document = GetDocument(databaseCommands);
						}
						catch (ConflictException e)
						{
							// resolving the conflict by selecting the highest number
							var highestMax = e.ConflictedVersionIds
								.Select(conflictedVersionId => GetMaxFromDocument(databaseCommands.Get(conflictedVersionId), minNextMax))
								.Max();

							PutDocument(databaseCommands, new JsonDocument
							{
								Etag = e.Etag,
								Metadata = new RavenJObject(),
								DataAsJson = RavenJObject.FromObject(new { Max = highestMax }),
								Key = HiLoDocumentKey
							});

							continue;
						}

						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;
						}
						PutDocument(databaseCommands, document);

						return new RangeValue(min, max);
					}
					catch (ConcurrencyException)
					{
						// expected, we need to retry
					}
				}
			}
		}
开发者ID:cocytus,项目名称:ravendb,代码行数:69,代码来源:HiLoKeyGenerator.cs


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