private static async Task SetupExpiration(DocumentStore store) { var config = new ExpirationConfiguration { Disabled = false, DeleteFrequencyInSec = 100, }; await store.Maintenance.Server.SendAsync(new ConfigureExpirationOperation(config, store.Database)); }
private static async Task SetupExpiration(DocumentStore store) { var config = new ExpirationConfiguration { Active = true, DeleteFrequencyInSec = 100, }; await store.Admin.Server.SendAsync(new ConfigureExpirationOperation(config, store.Database)); }
private void WriteExpiration(ExpirationConfiguration expiration) { if (expiration == null) { _writer.WriteNull(); return; } _context.Write(_writer, expiration.ToJson()); }
private async Task SetupExpiration(DocumentStore store) { var config = new ExpirationConfiguration { Disabled = false, DeleteFrequencyInSec = 100, }; await ExpirationHelper.SetupExpiration(store, Server.ServerStore, config); }
private static void SetupExpiration(IDocumentStore store) { using (var session = store.OpenSession()) { var config = new ExpirationConfiguration { Active = true, DeleteFrequencyInSec = 100, }; store.Admin.Server.Send(new ConfigureExpirationOperation(config, store.Database)); session.SaveChanges(); } }
private static void SetupExpiration(IDocumentStore store) { using (var session = store.OpenSession()) { var config = new ExpirationConfiguration { Disabled = false, DeleteFrequencyInSec = 100, }; store.Maintenance.Send(new ConfigureExpirationOperation(config)); session.SaveChanges(); } }
private async Task <bool> DisableExpiration(IDocumentStore store) { var config = new ExpirationConfiguration { Disabled = true, DeleteFrequencyInSec = 100, }; await ExpirationHelper.SetupExpiration(store, Server.ServerStore, config); var database = await Databases.GetDocumentDatabaseInstanceFor(store); return(database.ExpiredDocumentsCleaner != null); }
private static async Task SetupExpiration(DocumentStore store) { using (var session = store.OpenAsyncSession()) { var config = new ExpirationConfiguration { Active = true, DeleteFrequencyInSec = 100, }; await store.Admin.Server.SendAsync(new ConfigureExpirationOperation(config, store.Database)); await session.SaveChangesAsync(); } }
private static async Task SetupExpiration(DocumentStore store) { using (var session = store.OpenAsyncSession()) { var config = new ExpirationConfiguration { Disabled = false, DeleteFrequencyInSec = 100, }; await store.Maintenance.SendAsync(new ConfigureExpirationOperation(config)); await session.SaveChangesAsync(); } }
private async Task SetupExpiration(DocumentStore store) { using (var session = store.OpenAsyncSession()) { var config = new ExpirationConfiguration { Disabled = false, DeleteFrequencyInSec = 100, }; await ExpirationHelper.SetupExpiration(store, Server.ServerStore, config); await session.SaveChangesAsync(); } }
private void WriteExpiration(ExpirationConfiguration expiration) { if (expiration == null) { _writer.WriteNull(); return; } _writer.WriteStartObject(); _writer.WritePropertyName(nameof(expiration.Disabled)); _writer.WriteBool(expiration.Disabled); if (expiration.DeleteFrequencyInSec.HasValue) { _writer.WriteComma(); _writer.WritePropertyName(nameof(expiration.DeleteFrequencyInSec)); _writer.WriteString(expiration.DeleteFrequencyInSec.Value.ToString()); } _writer.WriteEndObject(); }
public static async Task SetupExpiration(IDocumentStore store, Raven.Server.ServerWide.ServerStore serverStore, ExpirationConfiguration configuration) { if (store == null) { throw new ArgumentNullException(nameof(store)); } if (serverStore == null) { throw new ArgumentNullException(nameof(serverStore)); } if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } var result = await store.Maintenance.SendAsync(new ConfigureExpirationOperation(configuration)); var documentDatabase = await serverStore.DatabasesLandlord.TryGetOrCreateResourceStore(store.Database); await documentDatabase.RachisLogIndexNotifications.WaitForIndexNotification(result.RaftCommandIndex.Value, serverStore.Engine.OperationTimeout); }
public async Task CanDeleteAllExpiredDocsAfterRunningTheExpirationBundle() { using (var store = GetDocumentStore()) { var config = new ExpirationConfiguration { Disabled = false, DeleteFrequencyInSec = 1000 }; await ExpirationHelper.SetupExpiration(store, Server.ServerStore, config); var expiry = SystemTime.UtcNow.AddMinutes(-5); var deleteList = new List <string>(); var batchSize = 10; var batches = 5; for (var i = 0; i < batches; i++) { using (var session = store.OpenAsyncSession()) { for (var j = 0; j < batchSize; j++) { var item = new Item(); await session.StoreAsync(item); deleteList.Add(item.Id); var metadata = session.Advanced.GetMetadataFor(item); metadata[Constants.Documents.Metadata.Expires] = expiry.ToString(DefaultFormat.DateTimeOffsetFormatsToWrite); } await session.SaveChangesAsync(); } } using (var session = store.OpenAsyncSession()) { foreach (var toDelete in deleteList) { session.Delete(toDelete); } await session.SaveChangesAsync(); } string lastId; using (var session = store.OpenAsyncSession()) { var item = new Item(); await session.StoreAsync(item); lastId = item.Id; var metadata = session.Advanced.GetMetadataFor(item); metadata[Constants.Documents.Metadata.Expires] = SystemTime.UtcNow.AddMinutes(-1).ToString(DefaultFormat.DateTimeOffsetFormatsToWrite); await session.SaveChangesAsync(); } var database = await Databases.GetDocumentDatabaseInstanceFor(store); ValidateTotalExpirationCount(batchSize); var expiredDocumentsCleaner = database.ExpiredDocumentsCleaner; await expiredDocumentsCleaner.CleanupExpiredDocs(batchSize); ValidateTotalExpirationCount(0); using (var session = store.OpenAsyncSession()) { var item = await session.LoadAsync <Item>(lastId); Assert.Null(item); } void ValidateTotalExpirationCount(int expected) { using (database.DocumentsStorage.ContextPool.AllocateOperationContext(out DocumentsOperationContext context)) using (context.OpenReadTransaction()) { var currentTime = database.Time.GetUtcNow(); var options = new ExpirationStorage.ExpiredDocumentsOptions(context, currentTime, false, batchSize); var expired = database.DocumentsStorage.ExpirationStorage.GetExpiredDocuments(options, out _, CancellationToken.None); var totalCount = 0; if (expired != null) { foreach (var singleExpired in expired) { totalCount += singleExpired.Value.Count; } } Assert.Equal(expected, totalCount); } } } }
protected bool Equals(ExpirationConfiguration other) { return(Active == other.Active && DeleteFrequencyInSec == other.DeleteFrequencyInSec); }
public EditExpirationCommand(ExpirationConfiguration configuration, string databaseName, string uniqueRequestId) : base(databaseName, uniqueRequestId) { Configuration = configuration; }
public EditExpirationCommand(ExpirationConfiguration configuration, string databaseName) : base(databaseName) { Configuration = configuration; }
public ConfigureExpirationCommand(ExpirationConfiguration configuration, string databaseName) { _configuration = configuration; _databaseName = databaseName; }