I posted this issue in a Caching GitHub project for ASP.NET.
There is already a set of IDistributedCache extension methods here that we can add (all of this is open source, so we can fix it ourselves and send a pull request :)).
Note that BinaryFormatter is not available in .NET Core (not sure if it will ever be), so I wrapped it with #if DNX451 and included the BinaryWriter and BinaryReader extension methods that can be used at both times. Also note that if you use the BinaryFormatter extension methods, you will need to add the [Serializable] attribute to your objects that you want to serialize.
public static class CacheExtensions { // Omitted existing extension methods... public static async Task<bool> GetBooleanAsync(this IDistributedCache cache, string key) { byte[] bytes = await cache.GetAsync(key); using (MemoryStream memoryStream = new MemoryStream(bytes)) { BinaryReader binaryReader = new BinaryReader(memoryStream); return binaryReader.ReadBoolean(); } } public static async Task<char> GetCharAsync(this IDistributedCache cache, string key) { byte[] bytes = await cache.GetAsync(key); using (MemoryStream memoryStream = new MemoryStream(bytes)) { BinaryReader binaryReader = new BinaryReader(memoryStream); return binaryReader.ReadChar(); } } public static async Task<decimal> GetDecimalAsync(this IDistributedCache cache, string key) { byte[] bytes = await cache.GetAsync(key); using (MemoryStream memoryStream = new MemoryStream(bytes)) { BinaryReader binaryReader = new BinaryReader(memoryStream); return binaryReader.ReadDecimal(); } } public static async Task<double> GetDoubleAsync(this IDistributedCache cache, string key) { byte[] bytes = await cache.GetAsync(key); using (MemoryStream memoryStream = new MemoryStream(bytes)) { BinaryReader binaryReader = new BinaryReader(memoryStream); return binaryReader.ReadDouble(); } } public static async Task<short> GetShortAsync(this IDistributedCache cache, string key) { byte[] bytes = await cache.GetAsync(key); using (MemoryStream memoryStream = new MemoryStream(bytes)) { BinaryReader binaryReader = new BinaryReader(memoryStream); return binaryReader.ReadInt16(); } } public static async Task<int> GetIntAsync(this IDistributedCache cache, string key) { byte[] bytes = await cache.GetAsync(key); using (MemoryStream memoryStream = new MemoryStream(bytes)) { BinaryReader binaryReader = new BinaryReader(memoryStream); return binaryReader.ReadInt32(); } } public static async Task<long> GetLongAsync(this IDistributedCache cache, string key) { byte[] bytes = await cache.GetAsync(key); using (MemoryStream memoryStream = new MemoryStream(bytes)) { BinaryReader binaryReader = new BinaryReader(memoryStream); return binaryReader.ReadInt64(); } } public static async Task<float> GetFloatAsync(this IDistributedCache cache, string key) { byte[] bytes = await cache.GetAsync(key); using (MemoryStream memoryStream = new MemoryStream(bytes)) { BinaryReader binaryReader = new BinaryReader(memoryStream); return binaryReader.ReadSingle(); } } public static async Task<string> GetStringAsync(this IDistributedCache cache, string key) { byte[] bytes = await cache.GetAsync(key); using (MemoryStream memoryStream = new MemoryStream(bytes)) { BinaryReader binaryReader = new BinaryReader(memoryStream); return binaryReader.ReadString(); } } public static Task SetAsync(this IDistributedCache cache, string key, bool value, DistributedCacheEntryOptions options) { byte[] bytes; using (MemoryStream memoryStream = new MemoryStream()) { BinaryWriter binaryWriter = new BinaryWriter(memoryStream); binaryWriter.Write(value); bytes = memoryStream.ToArray(); } return cache.SetAsync(key, bytes, options); } public static Task SetAsync(this IDistributedCache cache, string key, char value, DistributedCacheEntryOptions options) { byte[] bytes; using (MemoryStream memoryStream = new MemoryStream()) { BinaryWriter binaryWriter = new BinaryWriter(memoryStream); binaryWriter.Write(value); bytes = memoryStream.ToArray(); } return cache.SetAsync(key, bytes, options); } public static Task SetAsync(this IDistributedCache cache, string key, decimal value, DistributedCacheEntryOptions options) { byte[] bytes; using (MemoryStream memoryStream = new MemoryStream()) { BinaryWriter binaryWriter = new BinaryWriter(memoryStream); binaryWriter.Write(value); bytes = memoryStream.ToArray(); } return cache.SetAsync(key, bytes, options); } public static Task SetAsync(this IDistributedCache cache, string key, double value, DistributedCacheEntryOptions options) { byte[] bytes; using (MemoryStream memoryStream = new MemoryStream()) { BinaryWriter binaryWriter = new BinaryWriter(memoryStream); binaryWriter.Write(value); bytes = memoryStream.ToArray(); } return cache.SetAsync(key, bytes, options); } public static Task SetAsync(this IDistributedCache cache, string key, short value, DistributedCacheEntryOptions options) { byte[] bytes; using (MemoryStream memoryStream = new MemoryStream()) { BinaryWriter binaryWriter = new BinaryWriter(memoryStream); binaryWriter.Write(value); bytes = memoryStream.ToArray(); } return cache.SetAsync(key, bytes, options); } public static Task SetAsync(this IDistributedCache cache, string key, int value, DistributedCacheEntryOptions options) { byte[] bytes; using (MemoryStream memoryStream = new MemoryStream()) { BinaryWriter binaryWriter = new BinaryWriter(memoryStream); binaryWriter.Write(value); bytes = memoryStream.ToArray(); } return cache.SetAsync(key, bytes, options); } public static Task SetAsync(this IDistributedCache cache, string key, long value, DistributedCacheEntryOptions options) { byte[] bytes; using (MemoryStream memoryStream = new MemoryStream()) { BinaryWriter binaryWriter = new BinaryWriter(memoryStream); binaryWriter.Write(value); bytes = memoryStream.ToArray(); } return cache.SetAsync(key, bytes, options); } public static Task SetAsync(this IDistributedCache cache, string key, float value, DistributedCacheEntryOptions options) { byte[] bytes; using (MemoryStream memoryStream = new MemoryStream()) { BinaryWriter binaryWriter = new BinaryWriter(memoryStream); binaryWriter.Write(value); bytes = memoryStream.ToArray(); } return cache.SetAsync(key, bytes, options); } public static Task SetAsync(this IDistributedCache cache, string key, string value, DistributedCacheEntryOptions options) { byte[] bytes; using (MemoryStream memoryStream = new MemoryStream()) { BinaryWriter binaryWriter = new BinaryWriter(memoryStream); binaryWriter.Write(value); bytes = memoryStream.ToArray(); } return cache.SetAsync(key, bytes, options); }