diff --git a/docs/AspectCore.md b/docs/AspectCore.md index fb2a0848..51b0583c 100644 --- a/docs/AspectCore.md +++ b/docs/AspectCore.md @@ -34,7 +34,7 @@ Property | Description | Apply ---|---|--- CacheKeyPrefix | To specify the prefix of your cache key | All CacheProviderName | To specify which provider you want to use | All -IsHightAvailability | Whether caching opreation will break your method | All +IsHighAvailability | Whether caching opreation will break your method | All Expiration | To specify the expiration of your cache item,the unit is second | EasyCachingAble and EasyCachingPut IsAll | Whether remove all the cached items start with the CacheKeyPrefix | EasyCachingEvict only IsBefore | Remove the cached item before method excute or after method excute | EasyCachingEvict only diff --git a/docs/Castle.md b/docs/Castle.md index 83c82d94..891a1d86 100644 --- a/docs/Castle.md +++ b/docs/Castle.md @@ -34,7 +34,7 @@ Property | Description | Apply ---|---|--- CacheKeyPrefix | To specify the prefix of your cache key | All CacheProviderName | To specify which provider you want to use | All -IsHightAvailability | Whether caching opreation will break your method | All +IsHighAvailability | Whether caching opreation will break your method | All Expiration | To specify the expiration of your cache item,the unit is second | EasyCachingAble and EasyCachingPut IsAll | Whether remove all the cached items start with the CacheKeyPrefix | EasyCachingEvict only IsBefore | Remove the cached item before method excute or after method excute | EasyCachingEvict only diff --git a/src/EasyCaching.Core/Interceptor/EasyCachingInterceptorAttribute.cs b/src/EasyCaching.Core/Interceptor/EasyCachingInterceptorAttribute.cs index bb1e9a12..e3a14348 100644 --- a/src/EasyCaching.Core/Interceptor/EasyCachingInterceptorAttribute.cs +++ b/src/EasyCaching.Core/Interceptor/EasyCachingInterceptorAttribute.cs @@ -31,7 +31,7 @@ public class EasyCachingInterceptorAttribute : Attribute /// Prevent cache provider errors from affecting business /// /// The cache key prefix. - public bool IsHightAvailability { get; set; } = true; + public bool IsHighAvailability { get; set; } = true; } /// diff --git a/src/EasyCaching.Interceptor.AspectCore/EasyCachingInterceptor.cs b/src/EasyCaching.Interceptor.AspectCore/EasyCachingInterceptor.cs index 812ef158..97a94f76 100644 --- a/src/EasyCaching.Interceptor.AspectCore/EasyCachingInterceptor.cs +++ b/src/EasyCaching.Interceptor.AspectCore/EasyCachingInterceptor.cs @@ -107,7 +107,7 @@ private async Task ProceedAbleAsync(AspectContext context, AspectDelegate next) } catch (Exception ex) { - if (!attribute.IsHightAvailability) + if (!attribute.IsHighAvailability) { throw; } @@ -142,20 +142,20 @@ private async Task ProceedAbleAsync(AspectContext context, AspectDelegate next) // Invoke the method if we don't have a cache hit await next(context); - if (isAvailable) - { - // get the result - var returnValue = context.IsAsync() - ? await context.UnwrapAsyncReturnValue() - : context.ReturnValue; - + if (isAvailable) + { + // get the result + var returnValue = context.IsAsync() + ? await context.UnwrapAsyncReturnValue() + : context.ReturnValue; + // should we do something when method return null? // 1. cached a null value for a short time - // 2. do nothing - if (returnValue != null) - { - await _cacheProvider.SetAsync(cacheKey, returnValue, TimeSpan.FromSeconds(attribute.Expiration)); - } + // 2. do nothing + if (returnValue != null) + { + await _cacheProvider.SetAsync(cacheKey, returnValue, TimeSpan.FromSeconds(attribute.Expiration)); + } } } } @@ -194,7 +194,7 @@ private async Task ProcessPutAsync(AspectContext context) } catch (Exception ex) { - if (!attribute.IsHightAvailability) throw; + if (!attribute.IsHighAvailability) throw; else Logger?.LogError(new EventId(), ex, $"Cache provider \"{_cacheProvider.Name}\" set error."); } } @@ -230,7 +230,7 @@ private async Task ProcessEvictAsync(AspectContext context, bool isBefore) } catch (Exception ex) { - if (!attribute.IsHightAvailability) throw; + if (!attribute.IsHighAvailability) throw; else Logger?.LogError(new EventId(), ex, $"Cache provider \"{_cacheProvider.Name}\" remove error."); } } diff --git a/src/EasyCaching.Interceptor.Castle/EasyCachingInterceptor.cs b/src/EasyCaching.Interceptor.Castle/EasyCachingInterceptor.cs index a911f43c..b3eb2f11 100644 --- a/src/EasyCaching.Interceptor.Castle/EasyCachingInterceptor.cs +++ b/src/EasyCaching.Interceptor.Castle/EasyCachingInterceptor.cs @@ -112,7 +112,7 @@ private void ProceedAble(IInvocation invocation) } catch (Exception ex) { - if (!attribute.IsHightAvailability) + if (!attribute.IsHighAvailability) { throw; } @@ -193,7 +193,7 @@ private void ProcessPut(IInvocation invocation) } catch (Exception ex) { - if (!attribute.IsHightAvailability) throw; + if (!attribute.IsHighAvailability) throw; else _logger?.LogError(new EventId(), ex, $"Cache provider \"{_cacheProvider.Name}\" set error."); } } @@ -230,7 +230,7 @@ private void ProcessEvict(IInvocation invocation, bool isBefore) } catch (Exception ex) { - if (!attribute.IsHightAvailability) throw; + if (!attribute.IsHighAvailability) throw; else _logger?.LogError(new EventId(), ex, $"Cache provider \"{_cacheProvider.Name}\" remove error."); } }