/// <summary> /// Constructs a new CacheEntry. /// </summary> /// <param name="key">The primary key information for this entry.</param> /// <param name="varyHeaders">The Vary Header values for this entry.</param> /// <exception cref="ArgumentNullException">If <paramref name="key"/> is <c>null</c></exception> /// <exception cref="ArgumentNullException">If <paramref name="varyHeaders"/> is <c>null</c></exception> public CacheEntry(PrimaryCacheKey key, IEnumerable <string> varyHeaders) { Contract.Requires <ArgumentNullException>(key != null, "key"); Contract.Requires <ArgumentNullException>(varyHeaders != null, "varyHeaders"); Key = key; VaryHeaders = varyHeaders; }
public async Task StoreResponseAsync(HttpResponseMessage response) { var primaryCacheKey = new PrimaryCacheKey(response.RequestMessage.RequestUri, response.RequestMessage.Method); CacheEntry cacheEntry = await _contentStore.GetEntryAsync(primaryCacheKey) ?? new CacheEntry(primaryCacheKey, response.Headers.Vary); var content = cacheEntry.CreateContent(response); await _contentStore.UpdateEntryAsync(content); }
public Task <CacheEntry> GetEntryAsync(PrimaryCacheKey cacheKey) { // NB: Task.FromResult doesn't exist in MS.BCL.Async TaskCompletionSource <CacheEntry> ret = new TaskCompletionSource <CacheEntry>(); if (_responseCache.ContainsKey(cacheKey)) { ret.SetResult(_responseCache[cacheKey].CacheEntry); } else { ret.SetResult(null); } return(ret.Task); }
internal CacheEntry(PrimaryCacheKey key, HttpHeaderValueCollection <string> varyHeaders) { Key = key; VaryHeaders = varyHeaders; }