On Wednesday 30 January 2002 22:36, [EMAIL PROTECTED] wrote: > Hi, > > What do I need to do so that Tangram will work with mod_perl. > My understanding is that modules need to save their global > state (like tangram cache and stuff) in some shared memory spot > so that several mod_perl processes work on correct data. > > Is my understanding correct ? I tried using tangram blindly > and got into all problems with getting the wrong data from > other mod_perl processes. > > Btw, i am using tangram with AxKit (http://axkit.org). > > Thanks, > Boris > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED]
Yeah, thats an ugly one Boris. I don't think there is a real good answer either. I've built several object persistence systems for Perl, and here's the long and short of it. Most OOP modules, including Tangram, use tie and operator overloading to invisibly persist data and hide all the ugly details of persistence so that you can pretend you have just regular objects. The problem is twofold. 1st of all in order to use perl's shared memory module you also have to rely on tie. tie can't be inherited or extended, so its not possible to make shared Tangram objects. Furthermore, tieing for shared memory purposes is a very limited thing. Tie can only detect changes to the top level of your data structure (ie, if your object has a ref to another object, or if it is a hash of arrays or hashes then changes to the referenced objects/hashes/arrays will not be shared automatically). There is no way around this. You CAN design an OOP system which will do what you want, and I've been working on one, but it will NOT be transparent to your code like Tangram, you will have to explicitly commit objects back to the object store in your code. LIkewise you will have to code explicitly to make sure that referenced objects are properly shared between processes if that is important to you. Generally speaking my approach has been to never maintain objects in apache process memory between requests. Since you need some sort of shared memory anyway, just use your database for that. I've done performance testing, and with reasonable loads MySQL can dish out data 99.8% as fast as shared memory segments can. In fact except under the most extreme loads it is actually faster to just fetch your objects from the RDBMS every time you want to use them and dump them back at the end of each request. Its also a LOT safer. Esp if you need any sort of transactional behaviour. Remember that in the real world you will also probably be replicating your database for reliability and recovery purposes, so you pretty much want your data to be IN that database as much as possible, not hanging out in memory where it can be lost in the next crash. All that being said, Tangram is pretty nifty, just not really appropriate IMHO for mod_perl webapps. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
