How to use Esent with Esent managed shell?

I tried to follow the examples, using the Using statement to open an instance, create a session, attach to the database, open it, and then perform some operations, such as opening a transaction and saving the record. But when I use this template for every operation. Each save operation takes about 0.5 seconds. Therefore, I think that I am doing it wrong. but I'm not sure how I should do it.

Should I have only one instance? can i have more if they are called differently?

can i / should i have more if i have multiple threads?

I see that I can open several sessions at the same time, I think that everything is in order, but do I need to connect every session? Should I open a database for each session? I get inconsistent results when I test these different scenarios. Sometimes my tests pass sometimes, I get exceptions, for example, trying to use a located object or an EsentTempPathInUseException.

So, are there any recommendations as to how I should use this?

+4
source share
1 answer

I found these answers elswhere or through trial and error, but for those who see them here ...

You should have only one instance, since the instance is very expensive, it really creates a database and because it cures itself of unexpected closure, it can run these routines, if necessary. you cannot open more than one instance, if you call it something else, it will create a second instance different from the first. If you overlap them, you will receive an error message.

No problems with multi-threaded connection. Open the database once. Attach a session once. Sessions should not go through streams. You can have multiple threads with their own sessions, each of which accesses a database. Make sure you have escent managed objects. SO follow the examples to use the Usage instructions or to make sure objects destroy them.

An EsentTempPathInUseException throws an attempt to open a second instance while the current instance is still in use.

The exception exceptions for the object that I had were due to the fact that I blocked the creation and layout of Managed Esent objects when I shouldn't be.

+9
source

Source: https://habr.com/ru/post/1434763/


All Articles