hhblaze / DBreeze

C# .NET NOSQL ( key value store embedded ) ACID multi-paradigm database management system.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature-Request: Option to Restart DBEngine

thecodrr opened this issue · comments

How this would help?
In some cases (like when you dispose the DBEngine only to start it again), it would be good to have the option to restart the engine instead.

Current Behaviour:
The DBEngine needs to be disposed and initialized like this:

//_db is the DBEngine
_db.Dispose();
_db =null;
  var dbConfig = new DBreezeConfiguration
                {
                    DBreezeDataFolderName = dbPath,
                    Storage = DBreezeConfiguration.eStorage.DISK
                };
                _db = new DBreezeEngine(dbConfig);

As you can see, it would be good to just have this:

_db.Restart();

The difference will be in NOT creating a new instance on every disposal but just re initializing the old one. Currently there is no method for this or to make this happen in SHORT precise way.

Something else that could be done is to have an InitDB function, which would reduce the above code down to:

_db.Dispose();
_db.InitDB();

Thanks.

commented

Not a correct usage. DB engine should be a static variable, that instantiates on start and never disposes.

@hhblaze that is where you are wrong. I have an app that has an in-built "Reset" option. When a user presses that button, it first disposes the Database (without closing the app) and then it clears all the cache and the Database Folder.

I too use the Database as a static variable but sometimes, there is a need to dispose before the end of application cycle. I think a "Restart" option would be helpful here.

commented

DBreeze knows nothing about your external reference, external _db variable, so it can "restart" only its instance. But DBreeze doesn't need that, if works properly. If works improperly only outside of DBreeze it is possible to create new instance and assign to external _db variable.
So better you use _db=new DBreeze(_db.DBreezeConfiguration)...the only problem DBreezeConfiguration is internal variable (but this is solvable, right?)