title: Number of expiring keys listed by info command on redis slave not consistent with what I see
body: <p>When I run the <code>info</code> command in <code>redis-cli</code> against a redis 3.2.4 server, it shows me this for expires:</p>
  
  <p><code>expires=223518</code></p>
  
  <p>However, when I then run a <code>keys *</code> command and ask for the <code>ttl</code> for each key, and only print out keys with a ttl > 0, I only see a couple hundred.</p>
  
  <p>I thought that the <code>expires</code> is a count of the number of expiring keys but I am not even within an order of magnitude of this number.</p>
  
  <p>Can someone clarify exactly what <code>expires</code> is meant to convey? Does this include both to-be-expired and previously expired but not yet evicted keys?</p>
  
  <hr>
  
  <p>Update: </p>
  
  <p>Here is how I counted the number of keys expiring:</p>
  
  <pre><code>  task count_tmp_keys: :environment do
      redis = Redis.new(timeout: 100)
      keys = redis.keys '*'
      ct_expiring = 0
  
      keys.each do |k|
        ttl = redis.ttl(k)
        if ttl &gt; 0
          ct_expiring += 1
          puts "Expiring: #{k}; ttl is #{ttl}; total: #{ct_expiring}"
          STDOUT.flush
        end
      end
  
      puts "Total expiring: #{ct_expiring}"
      puts "Done at #{Time.now}"
    end
  </code></pre>
  
  <p>When I ran this script it shows I have a total expiring of 78</p>
  
  <p>When I run info, it says <code>db0:keys=10237963,expires=224098,avg_ttl=0</code></p>
  
  <p>Because 224098 is so much larger than 78, I am very confused. Is there perhaps a better way for me to obtain a list of all 225k expiring keys?</p>
  
  <p>Also, how is it that my average ttl is 0? Wouldn't you expect it to be nonzero?</p>
  
  <hr>
  
  <p><strong>UPDATE</strong> </p>
  
  <p>I have new information and a simple, 100% repro of this situation locally!</p>
  
  <p>To repro: setup two redis processes locally on your laptop. Make one a slave of the other. On the slave process, set the following:</p>
  
  <pre><code>config set slave-serve-stale-data yes
  config set slave-read-only no
  </code></pre>
  
  <p>Now, connect to the slave (not the master) and run:</p>
  
  <pre><code>set foo 1
  expire foo 10
  </code></pre>
  
  <p>After 10 seconds, you will no longer be able to access foo, but <code>info</code> command will still show that you have 1 key expiring with an average ttl of 0.</p>
  
  <p>Can someone explain this behavior?</p>