Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

RavenDB-323 Add a way to get last doc and attachment etags

  • Loading branch information...
commit 7abdc437af625b3fbdde29b767c62e8b4617db9b 1 parent 1abdfb2
@ayende ayende authored
View
2  Raven.Abstractions/Data/DatabaseStatistics.cs
@@ -10,6 +10,8 @@ namespace Raven.Abstractions.Data
{
public class DatabaseStatistics
{
+ public Guid LastDocEtag { get; set; }
+ public Guid LastAttachmentEtag { get; set; }
public int CountOfIndexes { get; set; }
public long ApproximateTaskCount { get; set; }
View
3  Raven.Database/DocumentDatabase.cs
@@ -273,6 +273,9 @@ public DatabaseStatistics Statistics
TransactionalStorage.Batch(actions =>
{
+ result.LastDocEtag = actions.Staleness.GetMostRecentDocumentEtag();
+ result.LastAttachmentEtag = actions.Staleness.GetMostRecentAttachmentEtag();
+
result.ApproximateTaskCount = actions.Tasks.ApproximateTaskCount;
result.CountOfDocuments = actions.Documents.GetDocumentsCount();
result.StaleIndexes = IndexStorage.Indexes
View
1  Raven.Database/Storage/IStalenessStorageActions.cs
@@ -16,6 +16,7 @@ public interface IStalenessStorageActions
Tuple<DateTime, Guid> IndexLastUpdatedAt(string name);
Guid GetMostRecentDocumentEtag();
+ Guid GetMostRecentAttachmentEtag();
Guid? GetMostRecentReducedEtag(string name);
int GetIndexTouchCount(string indexName);
}
View
11 Raven.Storage.Esent/StorageActions/Staleness.cs
@@ -157,6 +157,17 @@ public Guid GetMostRecentDocumentEtag()
return new Guid(lastEtag);
}
+ public Guid GetMostRecentAttachmentEtag()
+ {
+ Api.JetSetCurrentIndex(session, Files, "by_etag");
+ if (!Api.TryMoveLast(session, Files))
+ {
+ return Guid.Empty;
+ }
+ var lastEtag = Api.RetrieveColumn(session, Files, tableColumnsCache.DocumentsColumns["etag"]);
+ return new Guid(lastEtag);
+ }
+
public int GetIndexTouchCount(string name)
{
Api.JetSetCurrentIndex(session, IndexesEtags, "by_key");
View
10 Raven.Storage.Managed/StalenessStorageActions.cs
@@ -141,6 +141,16 @@ public Guid GetMostRecentDocumentEtag()
return Guid.Empty;
}
+ public Guid GetMostRecentAttachmentEtag()
+ {
+ foreach (var doc in storage.Attachments["ByEtag"].SkipFromEnd(0))
+ {
+ var docEtag = doc.Value<byte[]>("etag");
+ return new Guid(docEtag);
+ }
+ return Guid.Empty;
+ }
+
public Guid? GetMostRecentReducedEtag(string name)
{
var keyWithHighestEqualTo = storage.MappedResults["ByViewAndEtag"]
Please sign in to comment.
Something went wrong with that request. Please try again.