Skip to content

Commit

Permalink
Making sure that we explicitly disable the internal http cache when g…
Browse files Browse the repository at this point in the history
…etting the hilo document
  • Loading branch information
ayende committed Mar 13, 2013
1 parent 91b312a commit a5df7f0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
14 changes: 14 additions & 0 deletions Raven.Client.Lightweight/Connection/CreateHttpJsonRequestParams.cs
Expand Up @@ -7,12 +7,25 @@
#endif
using System.Linq;
using System.Net;
using Raven.Abstractions.Extensions;
using Raven.Client.Connection.Profiling;
using Raven.Client.Document;
using Raven.Json.Linq;

namespace Raven.Client.Connection
{
public static class HttpCacheSettings
{
[ThreadStatic]static internal bool avoidCachingRequest;

public static IDisposable AvoidUsingTheCacheForRequestsInThisScope()
{
var old = avoidCachingRequest;
avoidCachingRequest = true;
return new DisposableAction(() => avoidCachingRequest = old);
}
}

public class CreateHttpJsonRequestParams
{
public CreateHttpJsonRequestParams(IHoldProfilingInformation self, string url, string method, RavenJObject metadata, ICredentials credentials, DocumentConvention convention)
Expand All @@ -24,6 +37,7 @@ public CreateHttpJsonRequestParams(IHoldProfilingInformation self, string url, s
Credentials = credentials;
Convention = convention;
operationsHeadersCollection = new NameValueCollection();
AvoidCachingRequest = HttpCacheSettings.avoidCachingRequest;
}

/// <summary>
Expand Down
3 changes: 2 additions & 1 deletion Raven.Client.Lightweight/Document/HiLoKeyGenerator.cs
Expand Up @@ -68,6 +68,7 @@ public long NextId(IDatabaseCommands commands)
private RangeValue GetNextRange(IDatabaseCommands databaseCommands)
{
using (new TransactionScope(TransactionScopeOption.Suppress))
using (HttpCacheSettings.AvoidUsingTheCacheForRequestsInThisScope())
{
ModifyCapacityIfRequired();
while (true)
Expand Down Expand Up @@ -132,7 +133,7 @@ private RangeValue GetNextRange(IDatabaseCommands databaseCommands)
}
}

private void PutDocument(IDatabaseCommands databaseCommands,JsonDocument document)
private void PutDocument(IDatabaseCommands databaseCommands, JsonDocument document)
{
databaseCommands.Put(HiLoDocumentKey, document.Etag,
document.DataAsJson,
Expand Down

0 comments on commit a5df7f0

Please sign in to comment.