public void Flush() { if (_inmemoryCollection.IsActive) { var allModels = _inmemoryCollection.GetAll().ToArray(); if (allModels.Any()) { _storage.InsertBatch(allModels); } _inmemoryCollection.Deactivate(); } }
public async Task FlushAsync() { if (_inmemoryCollection.IsActive) { var allModels = _inmemoryCollection.GetAll().ToArray(); if (allModels.Length > 0) { await _storage.InsertBatchAsync(allModels).ConfigureAwait(false); } _inmemoryCollection.Deactivate(); } }