title: Limitations of redis.pipeline()
body: <p>Say I use <code>Redis</code> to create and maintain a hash <code>h[ url ] = t</code>, where <code>t</code> is the timestamp of the latest visit of the page <code>url</code>. So given an input <code>( url, newT )</code>, I want to do the following:</p>
  
  <ol>
  <li>check if <code>url</code> is a key of <code>h</code></li>
  <li>if not, set <code>h[ url ] = newT</code></li>
  <li>if it is, compare the old timestamp <code>h[ url ]</code> with <code>newT</code> , and update if <code>newT</code> is bigger</li>
  </ol>
  
  <p>Also I want to use <code>multiprocessing</code>, so I need to do this <strong>atomically</strong>. After reading the <a href="https://pypi.python.org/pypi/redis/" rel="nofollow">documentation</a>, I thought I could use <code>pipeline</code> to do this:</p>
  
  <blockquote>
    <p>In addition, pipelines can also ensure the buffered commands are
    executed atomically as a group. This happens by default.</p>
  </blockquote>
  
  <p>But then it says:</p>
  
  <blockquote>
    <p>A common issue occurs when requiring atomic transactions but needing
    to retrieve values in Redis prior for use within the transaction. For
    instance, let's assume that the INCR command didn't exist and we need
    to build an atomic version of INCR in Python.</p>
    
    <p>The completely naive implementation could GET the value, increment it
    in Python, and SET the new value back. However, this is not atomic
    because multiple clients could be doing this at the same time, each
    getting the same value from GET.</p>
    
    <p>Enter the WATCH command. [...]</p>
  </blockquote>
  
  <p>My understanding is that I cannot use <code>pipeline</code> if I want to read the value of <code>h[ url ]</code> prior to updating it. Is my understanding correct? Why isn't this possible?</p>