title: Optimistic locking with redis using GET and INCR
body: <p>I want to "lock" a block of code optimistically. 
  psuedo code is as follows:</p>
  
  <pre><code>revision = GET('lock_key') # default as 0
  {
  &lt;&lt;block of code&gt;&gt;
  }
  new_revision = INCR('lock_key')
  if new_revision != revision + 1:
      raise Exception # now retry or whatever
  </code></pre>
  
  <p>This looks fine to me since both INCR and GET are atomic.
  Do you see any problem with this approach?</p>