title: C# ServiceStack.Redis SetAll with expire
body: <p>First, a link to the library: <a href="https://github.com/ServiceStack/ServiceStack.Redis" rel="nofollow noreferrer">ServiceStack.Redis</a></p>
  
  <p>now, Im working on some generic cache mechanism which supports, for now, in 4 methods: </p>
  
  <p>Put, Get, PutMany, GetMany</p>
  
  <p>Problem is, whenever I want to insert numerous records, I dont have an option (visible to me) to add an expiration, unlike Put - where I can.</p>
  
  <p>The code is pretty streight forward:</p>
  
  <pre><code>public void PutMany(ICollection&lt;T&gt; items)
  {
      TimeSpan expiration = GetExpiration();
      DateTime expire = DateTime.UtcNow.Add(expiration);
  
      Dictionary&lt;string, CachedItem&lt;T&gt;&gt; dict = new Dictionary&lt;string, CachedItem&lt;T&gt;&gt;();
      foreach (T item in items)
      {
          CachedItem&lt;T&gt; cacheItem = new CachedItem&lt;T&gt;(item, expire);
  
          if (!dict.ContainsKey(cacheItem.Id))
              dict.Add(cacheItem.Id, cacheItem);
      }
  
      // Store item in cache
      _client.SetAll(dict);
  }
  </code></pre>
  
  <p>the model <code>CachedItem&lt;T&gt;</code> is mine, just imagine it as some sort of an object.</p>
  
  <p>As you can see, I dont have an option of setting the expiration.
  Is there a way (besides inserting them 1 by 1 using <code>_client.Set()</code>) to achieve this?</p>
  
  <p>TIA.</p>
  
  <p><strong>P.S</strong></p>
  
  <p>I know I can store all records in a list or an hash, I dont want that all the records will have a single expiration date (wrong, and can cause very serious performance issues whenever they expire)</p>