title: How to expire values not key?
body: <p>Now I have some mappings, A->(A1, A2, A3, A4), B->(B1, B2, B3)</p>
  
  <p>I wanna set the expire time of A1, A2, A3... as two days, so I can only get the values added within two days. And if all the values of A expired, the key A expired and should be deleted.</p>
  
  <p>What solution or database can achieve this feature?
  Thanks very much.</p>
  
  ####################################################-
  
  <p>Well, I should describe this problem in more detail. </p>
  
  <p>A lot of key-value pairs have been stored in Couchbase. And the key-value pairs are like this: <code>{id1_20170306-00:01:00 =&gt; value1} {id1_20170306-10:01:00 =&gt; value2} {id2_20170306-00:01:00 =&gt; value3}</code>. The expiration time for all key-value pairs is two days.</p>
  
  <p>When the user sends a request for <code>id1</code>, all the key-value pairs whose keys start with <code>id1</code> and not expired should be returned. </p>
  
  <p>I have a solution that is not particularly good. </p>
  
  <p>Convert the key to the start of the day. For <code>20170306-00:01:00</code> and <code>20170306-10:01:00</code>, it is <code>20170306-00:00:00</code>. Create a mapping like this
  <code>id1_20170306-00:00:00 =&gt; (id1_20170306-00:01:00,id1_20170306-10:01:00)</code>.</p>
  
  <p>Set the expiration time of <code>id1_20170306-00:00:00</code> to two days after the last modification.</p>
  
  <p>When the user sends a request for id1, keys like <code>id1_20170305-00:00:00</code> and <code>id1_20170306-00:00:00</code> are generated to access the real keys stored in Couchbase.</p>
  
  <p>Actually, the survive time of <code>id1_20170306-00:01:00</code> is over two days.</p>