On Fri, Sep 18, 2009 at 12:10 AM, Joe Baldwin <jfbaldwi..arthlink.net> wrote:
> That is pretty much what I was wanting to do (after listening to all the
> input). However, I am not sure how to implement this design in a webapp with
> session and a Cayenne filter that is creating the DataContext for me
> (automagically as they say).
The one created through the Cayenne filter is the session-based one.
Cayenne doesn't stop you from creating your own DataContexts to use
elsewhere (that are separate from the session-based one):
DataContext dc = DataContext.createDataContext();
> I suspect if I implement this sort of simple design (as about 95% of the
> result sets will be "read-only"), I could probably manage the memory much
> better.
>
> So how do I create a shared context? Is this going to be associated with an
> Application scoped singleton?
I used a singleton that controlled access to my shared objects. I
don't know how well that will scale since I didn't have to worry about
scalability (I had 3-5 users searching large amounts of data). I also
don't remember if DataContext is thread safe (what would happen it two
different threads did a performQuery() on the same DataContext). I'm
pretty sure I made my access methods on my singleton "synchronized" to
keep it safe. (Again, don't know how well that will scale.)
> Also how do I create the smaller contexts and
> make sure they are GC'd after the session is terminated?
DataContext dc = DataContext.createDataContext();
The easiest (and probably cheapest at this point) thing is still going
to be to add RAM. Seriously, what is the price difference between 128
MB and 256 MB with your hosting provider? And then compare that
difference to the cost of man hours trying to shave a few MB off your
memory footprint. If it takes you 4 man weeks to shave 50 MB (wild
guess) off your memory footprint, how many months of hosting at 256 MB
vs 128 MB will that buy you?
This archive was generated by hypermail 2.0.0 : Fri Sep 18 2009 - 09:24:53 EDT