public async Task <Stream> GetStreamAsync(string url, TimeSpan?duration = null) { string filename = _md5Helper.MD5(url); string filepath = Path.Combine(_diskCache.BasePath, filename); var stream = _diskCache.TryGetStream(filename); if (stream != null) { return(stream); } var data = await DownloadAndCacheAsync(url, filename, filepath, duration).ConfigureAwait(false); return(new MemoryStream(data)); }