title: Add Expiry to Redis Cache
body: <p>I have implemented Redis Cache in my C# project. I would just like to know how i can overload my <code>Get&lt;T&gt;</code> to also accept a timeout value. I figured this would be the best way to add an expiry to my redis cache provider. 
  Here is my code Below: </p>
  
  <pre><code>public async Task&lt;T&gt; GetAsync&lt;T&gt;(string key)
  {
      return (await _cacheClient.Db0.GetAsync&lt;T&gt;(key).ConfigureAwait(false));
  }
  /// &lt;summary&gt;
  /// Fetch item from cache
  /// &lt;/summary&gt;
  /// &lt;typeparam name="T"&gt;Return Type&lt;/typeparam&gt;
  /// &lt;param name="key"&gt;Key identifier in cache&lt;/param&gt;
  /// &lt;returns&gt;Cached item&lt;/returns&gt;
  public T Get&lt;T&gt;(string key)
  {
      return AsyncHelper.RunSync(() =&gt; _cacheClient.Db0.GetAsync&lt;T&gt;(key));
  
  }
  
  /// &lt;summary&gt;
  /// Fetch from cache, else execute operation and cache
  /// &lt;/summary&gt;
  /// &lt;typeparam name="T"&gt;Return Type&lt;/typeparam&gt;
  /// &lt;param name="key"&gt;Key identifier in cache&lt;/param&gt;
  /// &lt;param name="method"&gt;Method to execute&lt;/param&gt;
  /// &lt;param name="args"&gt;Method args&lt;/param&gt;
  /// &lt;returns&gt;&lt;/returns&gt;
  public async Task&lt;T&gt; GetAsync&lt;T&gt;(string key, Delegate method, params object[] args)
  {
      T result = default(T);
  
      try
      {
          if (await _cacheClient.Db0.ExistsAsync(key))
          {
              return await _cacheClient.Db0.GetAsync&lt;T&gt;(key);
          }
          else
          {
              result = ExecMethod&lt;T&gt;(method, args);
              await _cacheClient.Db0.AddAsync(key, result);
          }
      }
      catch (Exception ex)
      {
          _logHandler.LogError($"Error fetching cache for key:{key}", ex);
          result = ExecMethod&lt;T&gt;(method, args);
      }
  
      return result;
  }
  /// &lt;summary&gt;
  /// Fetch from cache, else execute operation and cache
  /// &lt;/summary&gt;
  /// &lt;typeparam name="T"&gt;Return Type&lt;/typeparam&gt;
  /// &lt;param name="key"&gt;Key identifier in cache&lt;/param&gt;
  /// &lt;param name="method"&gt;Method to execute&lt;/param&gt;
  /// &lt;param name="args"&gt;Method args&lt;/param&gt;
  /// &lt;returns&gt;&lt;/returns&gt;
  public T Get&lt;T&gt;(string key, Delegate method, params object[] args)
  {
      T result = default(T);
  
      try
      {
  
          if (AsyncHelper.RunSync(() =&gt; _cacheClient.Db0.ExistsAsync(key)))
          {
              result = AsyncHelper.RunSync(() =&gt; _cacheClient.Db0.GetAsync&lt;T&gt;(key));
          }
          else
          {
              result = ExecMethod&lt;T&gt;(method, args);
              var added = AsyncHelper.RunSync(() =&gt; _cacheClient.Db0.AddAsync(key, result));
          }
      }
      catch (Exception ex)
      {
          _logHandler.LogError($"Error fetching cache for key:{key}", ex);
          result = ExecMethod&lt;T&gt;(method, args);
      }
  
      return result;
  }
  </code></pre>