Closed vasiliy-vdovichenko closed 8 years ago
Use a new instance per request. Open database is cheap (read only 1 page) and process safe.
@mbdavid Is making new connections everytime you need to do something with LiteDB still the recommended approach for v4/v5 too? Right now (in IIS / .NET Core), we use a singleton service and re-use that all over the place with no particular issue, aside from the occasional drop of info between recycles.
Use a new instance per request. Open database is cheap (read only 1 page) and process safe.
Isn't that raccomandation directly in contrast with that one? https://github.com/mbdavid/LiteDB/issues/394
I know both the posts are old, but i am confused, shuld i reuse connection or not? I am in multi thread environment, not reusing connection, sometimes give you a file lock exception.
Should i switch to shared in the connection string? Or shared mean slow (as stated in the documentation).
Sorry for all these questions, but searching thorught different post i get different solution (sometimes opposite), i suppose becasue things change a bit over time.
@mbdavid Could you answer my question above? Is making new connections everytime you need to do something with LiteDB still the recommended approach for v4/v5 too? Right now (in IIS / .NET Core), we use a singleton service and re-use that all over the place with no particular issue, aside from the occasional drop of info between recycles.
We are however experiencing some deadlocks from time to time (see #1863), and was wondering if this could be because of the singleton? But we also don't want to get rid of the singleton uninformed.
@LennardF1989 Can you try this https://github.com/mbdavid/LiteDB/issues/1546#issuecomment-828674465 I tried with the provided test case and it's okay.
Any updates on this? @mbdavid
I am trying to have one instance of LiteDatabase for entire application (multiple thread may access the instance simultaneously) and just save changes to disk when some entities are modified. Is such scenario possible in v2 ? Or it would be better to create LiteDatabase for each time when access to DB is needed?