public static async Task <MemoryDatabase> LoadFromAsync(string path, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); MemoryClusterHandler cluster = null; MemoryDatabaseHandler db = null; try { cluster = new MemoryClusterHandler(); db = cluster.OpenDatabase(Guid.Empty); // load the snapshot from the disk var options = new MemorySnapshotOptions(); //TODO! await db.LoadSnapshotAsync(path, options, cancellationToken); return(new MemoryDatabase(new FdbCluster(cluster, ":memory:"), db, "DB", FdbSubspace.Empty, null, false, true)); } catch (Exception) { if (db != null) { db.Dispose(); } if (cluster != null) { cluster.Dispose(); } throw; } }
public Task SaveSnapshotAsync(string path, MemorySnapshotOptions options = null, CancellationToken cancellationToken = default(CancellationToken)) { if (path == null) { throw new ArgumentNullException("path"); } if (cancellationToken.IsCancellationRequested) { return(TaskHelpers.FromCancellation <object>(cancellationToken)); } options = options ?? new MemorySnapshotOptions() { Mode = MemorySnapshotMode.Full }; return(m_handler.SaveSnapshotAsync(path, options, cancellationToken)); }
public static async Task<MemoryDatabase> LoadFromAsync(string path, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); MemoryClusterHandler cluster = null; MemoryDatabaseHandler db = null; try { cluster = new MemoryClusterHandler(); db = cluster.OpenDatabase(Guid.Empty); // load the snapshot from the disk var options = new MemorySnapshotOptions(); //TODO! await db.LoadSnapshotAsync(path, options, cancellationToken); return new MemoryDatabase(new FdbCluster(cluster, ":memory:"), db, "DB", FdbSubspace.Empty, null, false, true); } catch(Exception) { if (db != null) db.Dispose(); if (cluster != null) cluster.Dispose(); throw; } }
public Task SaveSnapshotAsync(string path, MemorySnapshotOptions options = null, CancellationToken cancellationToken = default(CancellationToken)) { if (path == null) throw new ArgumentNullException("path"); if (cancellationToken.IsCancellationRequested) return TaskHelpers.FromCancellation<object>(cancellationToken); options = options ?? new MemorySnapshotOptions() { Mode = MemorySnapshotMode.Full }; return m_handler.SaveSnapshotAsync(path, options, cancellationToken); }