title: Combine Sliding and Absolute Expiration
body: <p>I want to use <code>System.Runtime.Caching.MemoryCache</code> for caching some of my objects. I want to be sure that the object is refreshed once a day (absolute expiration) but I also want to make it expire if it hasn't been used in the last hour (sliding expiration).
  I try to do:</p>
  <pre><code>object item = &quot;someitem&quot;;
  var cache = MemoryCache.Default;
  var policy = new CacheItemPolicy();
  policy.AbsoluteExpiration = DateTime.Now.AddDays(1);
  policy.SlidingExpiration = TimeSpan.FromHours(1);
  cache.Add(&quot;somekey&quot;, item, policy);
  </code></pre>
  <p>But I'm getting an error:</p>
  <blockquote>
  <p>&quot;ArgumentException&quot; with &quot;AbsoluteExpiration must be
  DateTimeOffset.MaxValue or SlidingExpiration must be TimeSpan.Zero.&quot;</p>
  </blockquote>