diff --git a/src/EasyCaching.ResponseCaching/EasyCachingResponseCache.cs b/src/EasyCaching.ResponseCaching/EasyCachingResponseCache.cs index 52935184..9b7cafd3 100644 --- a/src/EasyCaching.ResponseCaching/EasyCachingResponseCache.cs +++ b/src/EasyCaching.ResponseCaching/EasyCachingResponseCache.cs @@ -43,8 +43,7 @@ public IResponseCacheEntry Get(string key) if (entry.HasValue) { - var val = entry.Value as EasyCachingResponse; - if (val != null) + if (entry.Value is EasyCachingResponse val) { return new CachedResponse { @@ -70,8 +69,7 @@ public async Task GetAsync(string key) if (entry.HasValue) { - var val = entry.Value as EasyCachingResponse; - if (val != null) + if (entry.Value is EasyCachingResponse val) { return new CachedResponse { @@ -95,8 +93,7 @@ public async Task GetAsync(string key) /// Valid for. public void Set(string key, IResponseCacheEntry entry, TimeSpan validFor) { - var cachedResponse = entry as CachedResponse; - if (cachedResponse != null) + if (entry is CachedResponse cachedResponse) { _provider.Set( key, @@ -127,8 +124,7 @@ public void Set(string key, IResponseCacheEntry entry, TimeSpan validFor) /// Valid for. public async Task SetAsync(string key, IResponseCacheEntry entry, TimeSpan validFor) { - var cachedResponse = entry as CachedResponse; - if (cachedResponse != null) + if (entry is CachedResponse cachedResponse) { await _provider.SetAsync( key,