Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/AspectCore.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/Castle.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class EasyCachingInterceptorAttribute : Attribute
/// Prevent cache provider errors from affecting business
/// </summary>
/// <value>The cache key prefix.</value>
public bool IsHightAvailability { get; set; } = true;
public bool IsHighAvailability { get; set; } = true;
}

/// <summary>
Expand Down
30 changes: 15 additions & 15 deletions src/EasyCaching.Interceptor.AspectCore/EasyCachingInterceptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ private async Task ProceedAbleAsync(AspectContext context, AspectDelegate next)
}
catch (Exception ex)
{
if (!attribute.IsHightAvailability)
if (!attribute.IsHighAvailability)
{
throw;
}
Expand Down Expand Up @@ -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));
}
}
}
}
Expand Down Expand Up @@ -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.");
}
}
Expand Down Expand Up @@ -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.");
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/EasyCaching.Interceptor.Castle/EasyCachingInterceptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ private void ProceedAble(IInvocation invocation)
}
catch (Exception ex)
{
if (!attribute.IsHightAvailability)
if (!attribute.IsHighAvailability)
{
throw;
}
Expand Down Expand Up @@ -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.");
}
}
Expand Down Expand Up @@ -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.");
}
}
Expand Down