title: StackExchange.Redis casting RedisValue to byte[] via "as byte[]" returns null
body: <p>I'm trying to create a Redis provider for Strathweb.CacheOutput.WebApi2, but trying to convert from a byte[] -> RedisValue -> byte[] is returning null.</p>
  
  <p>I can manually set the object type as byte[] instead of var / RedisValue and it will correctly return the value as a byte[], but after it has been set as a RedisValue its failing to convert it to a byte[].</p>
  
  <p>His Interface has the Get always return an object so I can't force the type or use a separate call without having to modify the interface.</p>
  
  <p>If I try to do an <code>result as byte[]</code> I get
  <code>Cannot convert type 'StackExchange.Redis.RedisValue' to 'byte[]' via a reference conversion, boxing conversion, unboxing conversion, wrapping conversion, or null type conversion</code></p>
  
  <p>If I try to do a <code>(byte[])result</code> I get <code>Cannot cast 'result' (which has an actual type of 'StackExchange.Redis.RedisValue') to 'byte[]'</code></p>
  
  <p>Is there something I'm missing or am I going to have to hack it in somehow by checking what type of data its looking for based on the key?</p>
  
  <p>Here is the interface:</p>
  
  <pre><code>namespace WebApi.OutputCache.Core.Cache
  {
      public interface IApiOutputCache
      {
          void RemoveStartsWith(string key);
          T Get&lt;T&gt;(string key) where T : class;
          object Get(string key);
          void Remove(string key);
          bool Contains(string key);
          void Add(string key, object o, DateTimeOffset expiration, string dependsOnKey = null);
          IEnumerable&lt;string&gt; AllKeys { get; }
      }
  }
  </code></pre>
  
  <p>And here is how its called:</p>
  
  <pre><code>        var val = _webApiCache.Get(cachekey) as byte[];
          if (val == null) return;
  </code></pre>
  
  <p>Edit: Adding examples of the API I implemented using both ServiceStack.Redis v3 (working atm as it just uses <code>object</code> and StackExchange.Redis which is not working)</p>
  
  <p><a href="https://github.com/mackayj/WebApi.OutputCache.Redis.ServiceStack" rel="noreferrer">https://github.com/mackayj/WebApi.OutputCache.Redis.ServiceStack</a></p>
  
  <p><a href="https://github.com/mackayj/WebApi.OutputCache.Redis.StackExchange" rel="noreferrer">https://github.com/mackayj/WebApi.OutputCache.Redis.StackExchange</a></p>