On Tue, 2002-07-30 at 08:26, jonathan wrote
> 2. Should I have global access to 'store', or should each module where it is
> used create it's own store?? I noticed in the source for SQLObjectStore,
> that new connections are created all over the place anyway. So would this be
> much of a performance hit? how does everyone else do this??
This was a question on my mind when I started using MiddleKit, too.
Originally I had one store per servlet which used the store, but soon
realized that this is not how MiddleKit was designed to be used -- at
least not in that version, which was 0.6, since the store aggressively
cached objects, and changes made to objects in one store wouldn't be
noticed by other stores. I've noticed that a lot of this has changed in
0.7, so trying something like this might work now.
As I understand it, though, MiddleKit was designed to be instantiated as
a global instance (once per application). You can achieve this by
putting the init code in a module at file-level -- whichever module
imports it first will cause it to be instantiated.
The only question on my mind is whether there are concurrency issues if
multiple threads call store.saveChanges() simultaneously; from the code
it looks like this could be a problem. I haven't run into any problems
yet, but since I've done mostly single-user testing so far, it's likely
that this just hasn't come up. This could be solved by using a
semaphore or other lock -- but before I do that I'd be interested to
hear if anyone has thought about this possibility or experienced any
Jason D. Hildebrand