Exemple #1
0
        public async Task <byte[]> CreateCachedItemAsync(
            string key,
            byte[] value,
            CancellationToken token)
        {
            if (LocalCache != null)
            {
                _context.WriteEvent($"CacheCommunicationClient::CreateCachedItemAsync: Local: {key}");
                return(await LocalCache.CreateCachedItemAsync(key, value, token));
            }
            else
            {
                var builder = new UriBuilder(Url);
                builder.Path = $"/api/cache/{key}";
                _context.WriteEvent($"CacheCommunicationClient::CreateCachedItemAsync: Remote: {builder.Uri}");

                var byteContent = new ByteArrayContent(value);
                var ret         = await HttpClient.PostAsync(builder.Uri, byteContent);

                return(await ret.Content.ReadAsByteArrayAsync());
            }
        }