title: A race condition when using Redis command incr and expire
body: <p>Based on the redis document: <a href="http://redis.io/commands/incr" rel="noreferrer">http://redis.io/commands/incr</a></p>
  
  <p>In the paragraph Pattern: Rate Limiter 2
  A shorter version code:</p>
  
  <pre>
  value = INCR(ip)
  
  IF value == 1 THEN
    EXPIRE(ip, 1)
  </pre>
  
  <p>It's claimed there's a race condition to make EXPIRE never executes. Which means the value of ip can bounces from 0 to 2 some way.</p>
  
  <p>However in my thoughts, since Redis is single thread and INCR is a primitive command, it shouldn't be atomic itself? Even if 2 clients do the INCR at almost the same time, how could them both retrieve 0 or both retrieve 2?</p>