Thanks, I had no idea that Memcache was so capable (I haven't looked closely enough recently). You could absolutely build a semaphore using those methods (cas would do the job nicely). Except of course that it could disappear at any moment. I can't help thinking that there must be some way to cope with that, however. Worth a ponder!
On 27 October 2011 18:53, Murph <[email protected]> wrote: > I think it's basically possible to do locking, mutexes, semaphores, etc in > memcache, by taking advantage of some of the semantics, plus the new-ish > compare & store stuff. There's the obvious caveat that it could be flushed > without warning, or disabled for a while, so it's not a high reliability > thing. > > def add(self, key, value, time=0, min_compress_len=0, namespace=None): > """Sets a key's value, iff item is not already in memcache. > > def replace(self, key, value, time=0, min_compress_len=0, namespace=None): > """Replaces a key's value, failing if item isn't already in memcache. > > def cas(self, key, value, time=0, min_compress_len=0, namespace=None): > """Compare-And-Set update. > > def incr(self, key, delta=1, namespace=None, initial_value=None): > """Atomically increments a key's value. > > def decr(self, key, delta=1, namespace=None, initial_value=None): > """Atomically decrements a key's value. > > It seems to me the you could carefully use the above in various creative > ways to implement this, if you require frequent use and the datastore costs > would be prohibitive for it. > > -- > You received this message because you are subscribed to the Google Groups > "Google App Engine" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/google-appengine/-/cAlYR6jxlogJ. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/google-appengine?hl=en. > -- Emlyn http://my.syyn.cc - Synchonise Google+, Facebook, WordPress and Google Buzz posts, comments and all. http://point7.wordpress.com - My blog Find me on Facebook and Buzz -- You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.
