<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><BR><DIV><DIV>On May 14, 2007, at 8:25 , Julio Leyva wrote:</DIV><BR class="Apple-interchange-newline"><BLOCKQUOTE type="cite"><P style="margin: 0.0px 0.0px 0.0px 0.0px"><FONT face="Monaco" size="2" style="font: 10.0px Monaco">We have a transaction that must lock a key in a table and no any other parallel transaction can access that key until the first transaction is finished.</FONT></P> <P style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><BR></P> <P style="margin: 0.0px 0.0px 0.0px 0.0px"><FONT face="Monaco" size="2" style="font: 10.0px Monaco">We think that process will be faster using memcached.</FONT></P> </BLOCKQUOTE></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>The best that memcached could offer is a counter you could do something like a spinlock on.  That may very well be worse.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>It should be possible to parallelize your transactions, though.  Should all read processes stop just because something has indicated it may be changing in another process?  If you allow concurrent reads, then you memcache can help, but you can likely do away with the lock altogether.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>If you can defer  your concurrency checking to the *end* of the transaction, all you have to do is roll back whatever transaction didn't win and start it over.  I used to do something like this for a relatively concurrent system.  In my case, the number of transaction collisions was small enough that I never even bothered to replay the loser.  I'd just roll it back and return an error and let the other side deal with the failure.  I tracked all of the fields that changed, so resolving it would've been pretty simple, though.</DIV><BR><DIV> <SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><DIV>-- </DIV><DIV>Dustin Sallings</DIV><BR class="Apple-interchange-newline"></SPAN> </DIV><BR></BODY></HTML>