title: redis performance -- delete 100 records at maximum?
body: <p>I'm newbie to Redis, reading the book &lt; Redis in Action >, and in section 2.1 ("Login and cookie caching") there is a <code>clean_sessions</code> function:</p>
  
  <pre><code>QUIT = False
  LIMIT = 10000000
  
  def clean_session:
    while not QUIT:
      size = conn.zcard('recent:')
      if size &lt;= LIMIT:
        time.sleep(1)
        continue
  
      # find out the range in `recent:` ZSET
      end_index = min(size-LIMIT, 100)
      tokens = conn.zrange('recent:', 0, end_index-1)
  
      # delete corresponding data
      session_keys = []
      for token in tokens:
        session_keys.append('viewed:' + token)
  
      conn.delete(*session_keys)
      conn.hdel('login:', *tokens)
      conn.zrem('recent:', *tokens)
  </code></pre>
  
  <p>It deletes login token and corresponding data if there is more than 10 million records, the question is:</p>
  
  <ul>
  <li><p>why delete 100 records at most per time? </p></li>
  <li><p>why not just delete <code>size - LIMIT</code> records at once?</p></li>
  <li><p>is there some performance consideration?</p></li>
  </ul>
  
  <p>Thanks, all responses are appreciated :)</p>