title: TTL for a set member
body: <p>Is it possible in Redis to set TTL (time to live) not for a specific key, but for a member for a set?</p>
  
  <p>I am using a structure for tags proposed by Redis documentation - the data are simple key-value pairs, and the tags are sets containing keys corresponding to each tag, e.g.</p>
  
  <pre><code>&gt; SETEX id:id_1 100 'Lorem ipsum'
  OK
  &gt; SADD tag:tag_1 id:id_1
  (integer) 1
  </code></pre>
  
  <p>The key <code>id:id_1</code> will expire as expected but i don't see an efficient way to remove the corresponding member from the <code>tag:tag_1</code> set.</p>
  
  <p>One way I came up is using a cron job containing a script which would remove expired keys from sets periodically - by adding all the tag names to another set and then iterating through all the tags, then all the ids corresponding to each tag and checking if corresponding key exists - if not, calling <code>SREM</code>.</p>
  
  <p>I don't think it will be an efficient way and I would possibly like to keep the tags as clean as possible, because the size of the sets will probably affect performance of searching by multiple tags (<code>SINTER</code>). Is there a more "internal" way?</p>