From: Ian B. <ia...@co...> - 2003-04-16 21:06:13
|
On Tue, 2003-04-15 at 12:43, Frank Barknecht wrote: > Hallo, > > I'm haveing some problems with changed SQLObjects in Webware. Too > often the database itself is changed when I change an object, but the > cache is not expired. In Webware, being a threaded system, I then get > invalid data in other threads. > > As I only change objects in one place, I would love to be able to let > the cache expire by hand there, with something like > "mySqlobject.cache.expire()" I was thinking of something like that, only calling it .refresh(). What bothered me was if you do this at, say, the beginning of a request you may be confused when some other request does the same thing, and the object gets refreshed in the middle of your request. I'm thinking there needs to be some consolidation of the different ways instances act with respect to threads. There's a few use cases I can see: * You want a fresh instance at the beginning of your "transaction" (not necessarily a database transaction). You don't want that instance changing underneath you. * You want a live copy of the object, but only live for the process you're in. So all threads share a copy, but multiple processes could go out of sync. Works well with Webware when its the only user of a database, but I'm not sure outside of that. * You want a instance that's associated with a database transaction, with whatever semantics that implies. Obviously you may have multiple copies of the object, since multiple transactions could be occurring. * You want a live instance of the object, attached directly to the database. No caching should occur. There's no reason not to share this instance between threads, as far as I can see. More cases? Is there a way all these cases can be expressed more succinctly (like a couple options that can be combined in different ways)? Ian |