title: Caching Generic types of Objects with Redis using C#
body: <p>I'm creating a new feature here in my application to cache using AOP.
  When my method is called using <code>RedisCacheableResultAttribute</code> I will cache / retrieve the data.
  I'm successfully storing, don't know it's the correct way serializing and storing as string, but when I return the object from Redis I need convert to the type I stored at the first time. 
  I imagine that I can do it with reflection but no success, i'm not very experienced with reflection.</p>
  
  <pre><code>public sealed override void OnInvoke(MethodInterceptionArgs args)
  {
      var cache = RedisConnectorHelper.Connection.GetDatabase();
      var result = cache.StringGet(args.Method.Name); // retrieving from Redis
  
      if (result.HasValue)
      {
          args.ReturnValue = result; // here I need to convert back to the type I received when I stored.
          return;
      }
  
      base.OnInvoke(args);
      cache.StringSet(args.Method.Name, Serialize(args.ReturnValue)); //storing the data OK.
  }
  
  private string Serialize(object obj)
  {
      return JsonConvert.SerializeObject(obj);
  }
  </code></pre>