On Aug 26, 2011, at 11:32 PM, Tony Giaccone wrote:

> So as a first pass, it's going to be mostly read, but there will be some
> writing as well. And in later phases, there may be more substantial
> writing.
> 
> But that said, the intent is to make this basically a restful object store.
> 
> My basic design is to have Cayenne objects which live in the database, and
> then a DTO object which gets fed to the client through a json call.

Restful and stateless (no sessions) service is the best thing you can have :-)

So for read-only parts you can use a shared ObjectContext placed somewhere in 
the application scope. Combined with LOCAL_CACHE_STRATEGY this will give you 
the best performance. For write or read/write parts, create a new ObjectContext 
in each request to avoid race conditions on changing objects. 

In both cases you may bind the right ObjectContext instance to the request 
thread somewhere on entry, so that the underlying code doesn't have to think 
about it. But anyways, once you decide on the context scope, the the 
implementation details can vary - you can pick your favorite flavor.

Andrus

Reply via email to