Skip to content

Commit 719bfbc

Browse files
committed
update cached item definition
1 parent c573efc commit 719bfbc

File tree

4 files changed

+12
-19
lines changed

4 files changed

+12
-19
lines changed

src/OutputCacheModuleAsync/InMemoryOutputCacheProvider.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33
using System.Runtime.Caching;
44
using System.Threading.Tasks;
55
using System.Web.Caching;
6-
using Resource;
76

87
class InMemoryOutputCacheProvider : OutputCacheProviderAsync {
9-
private readonly MemoryCache _cache = new MemoryCache(SR.Microsoft_AspNet_OutputCache_Default_InMemory_Provider);
8+
private readonly MemoryCache _cache = new MemoryCache("Microsoft.AspNet.OutputCache Default In - Memory Provider");
109

1110
public override Task<object> GetAsync(string key) {
1211
return Task.FromResult(Get(key));

src/OutputCacheModuleAsync/OutputCacheModuleAsync.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,24 @@ private async Task OnEnterAsync(object source, EventArgs eventArgs) {
5959
// 'item' may be one of the following:
6060
// - a CachedVary object (if the object varies by something)
6161
// - a CachedRawResponse object (i.e. it doesn't vary on anything)
62-
// First assume it's a CacheVary
63-
object cachedItem = null;
62+
// First assume it's a CacheVary and try to get the cachedItem with it
63+
CachedRawResponse cachedRawResponse;
6464
var cachedVary = item as CachedVary;
6565
if (cachedVary != null) {
66-
cachedItem = await helper.GetAsCacheVaryAsync(cachedVary);
66+
var cachedItem = await helper.GetAsCacheVaryAsync(cachedVary);
67+
if (cachedItem == null) {
68+
return;
69+
}
70+
cachedRawResponse = (CachedRawResponse)cachedItem;
6771
}
68-
if (cachedItem == null) {
72+
else {
73+
cachedRawResponse = item as CachedRawResponse;
74+
}
75+
if (cachedRawResponse == null) {
6976
return;
7077
}
7178

7279
// From this point on, we have an Raw Response entry to work with.
73-
var cachedRawResponse = (CachedRawResponse)cachedItem;
7480
HttpCachePolicySettings settings = cachedRawResponse.CachePolicy;
7581
if (helper.CheckCachedVary(cachedVary, settings)) {
7682
return;

src/OutputCacheModuleAsync/Resource/SR.Designer.cs

Lines changed: 0 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/OutputCacheModuleAsync/Resource/SR.resx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,6 @@
123123
<data name="Cannot_use_snapshot_after_headers_sent" xml:space="preserve">
124124
<value>Cannot use snapshot after headers sent.</value>
125125
</data>
126-
<data name="Microsoft_AspNet_OutputCache_Default_InMemory_Provider" xml:space="preserve">
127-
<value>Microsoft.AspNet.OutputCache Default In-Memory Provider</value>
128-
</data>
129126
<data name="Provider_does_not_support_policy_for_responses" xml:space="preserve">
130127
<value>Provider does not support policy for responses.</value>
131128
</data>

0 commit comments

Comments
 (0)