How to use db4o IObjectContainer in a web application ? (Container lifetime ?)

Posted by driis on Stack Overflow See other posts from Stack Overflow or by driis
Published on 2010-03-21T17:38:52Z Indexed on 2010/03/21 17:41 UTC
Read the original article Hit count: 214

Filed under:
|
|
|

I am evaluating db4o for persistence for a ASP .NET MVC project.

I am wondering how I should use the IObjectContainer in a web context with regards to object lifetime. As I see it, I can do one of the following:

  1. Create the IObjectContainer at application startup and keep the same instance for the entire application lifetime.
  2. Create one IObjectContainer per request.
  3. Start a server, and get a client IObjectContainer for each database interaction.

What are the implications of these options, in terms of performance and concurrency ?

Since the database is locked when an IObjectContainer is opened, I am pretty sure that option 2) would get me some problems with concurrency - would this also be the case for option 1 ?

As I understand it, if I retrieve an object from an IObjectContainer, it must be saved by the same IObjectContainer instance - in order for db4o to identify it as being the same object. Therefore, If I choose option 3), I would have to retrieve the original object, make the necessary changes (copy data from a modified object), and then store it using the same IObjectContainer. Is this true ?

© Stack Overflow or respective owner

Related posts about db4o

Related posts about c#