On Jan 14, 2008 6:11 PM, Sancar Saran <sancar.saran@xxxxxxxxxx> wrote: > Hello Jochem, > > > > no not in the slightest. both those bits of code are identical for one > > (apart from the fact that neither are valid syntax). and whatever your > > trying to point out it's beside the point (I think). any possible race > > condition will be occuring with the code that *sets* data into memcache > (or > > whatever). > > > > I don't claim to know everything there is no know about race-conditions > but > > you can very easily program them into a php app that's for sure. please > do > > some reading on the matter (e.g. google 'memcache+race+condition') - I'm > > quite sure you'll find some interesting material - I know I did (just > now) > > > > Of course, my recent project uses heavly on memcached and race conditions > are > blown. So I have to implement some kind flag system to avoid race > conditions. > > And in same project I use $GLOBALS->['mc'] for storing memcached resource > object. > > and if I was use to store some kind of data in $GLOBALS i use > $GLOBALS['data'][] = $some_data; > > And of course without proper handling. You can blow yourself... > wow, we really are drifting on the initial topic of this thread here, but im going to chime in again. i think that php does not offer much in the way of managing synchronization of code that could potentially enter a race condition. the best thing youll see in the documentation (from what ive read of it) is file locks. and there is a good example of how to use them that someone has posted. but file locking for mutual exclusion is slow. ive implemented some synchronization code using the sysv sempaphores which is much faster than file locking, however not portable (though i wont be needing to port it to windows anyway ;)) java has a very nice construct, the synchronize keyword, which in my opinion is quite elegant. it is not the most performant, but i imagine it beats file locking and the best part is, its a native mechanism. facilitating mutual exclusion is a sore spot for me with php anyway. -nathan