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 static MemoryDatabase CreateNew(string name, IFdbSubspace globalSpace, bool readOnly) { globalSpace = globalSpace ?? FdbSubspace.Empty; var uid = Guid.NewGuid(); MemoryClusterHandler cluster = null; MemoryDatabaseHandler db = null; try { cluster = new MemoryClusterHandler(); db = cluster.OpenDatabase(uid); // initialize the system keys for this new db db.PopulateSystemKeys(); return(new MemoryDatabase(new FdbCluster(cluster, ":memory:"), db, name, globalSpace, null, readOnly, true)); } catch { if (db != null) { db.Dispose(); } if (cluster != null) { cluster.Dispose(); } throw; } }
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 static MemoryDatabase CreateNew(string name, IFdbSubspace globalSpace, bool readOnly) { globalSpace = globalSpace ?? FdbSubspace.Empty; var uid = Guid.NewGuid(); MemoryClusterHandler cluster = null; MemoryDatabaseHandler db = null; try { cluster = new MemoryClusterHandler(); db = cluster.OpenDatabase(uid); // initialize the system keys for this new db db.PopulateSystemKeys(); return new MemoryDatabase(new FdbCluster(cluster, ":memory:"), db, name, globalSpace, null, readOnly, true); } catch { if (db != null) db.Dispose(); if (cluster != null) cluster.Dispose(); throw; } }