public override async Task Invoke(AspectContext context, AspectDelegate next) { var currentCacheKey = Key.FillValue(context.GetParamsDictionary(), context.GetDefaultKey()); //返回值类型 var returnType = context.GetReturnType(); //从缓存取值 var cacheValue = GetCahceValue(currentCacheKey, returnType, context); if (cacheValue != null) { return; } //不加锁,直接返回 if (!ThreadLock) { await GetDirectValueWithSetCache(context, next, currentCacheKey, returnType); return; } using (await _lock.LockAsync()) { cacheValue = GetCahceValue(currentCacheKey, returnType, context); if (cacheValue != null) { return; } await GetDirectValueWithSetCache(context, next, currentCacheKey, returnType); } }