Exemplo n.º 1
0
        private bool CheckCacheKeyLock(IInvocation invocation, IRedisCacheService redisCacheService, ParameterInfo[] parameters, ServiceCacheAttribute svcCacheAttribute, string cacheKey)
        {
            var cacheKeyLocked = string.Format("{0}:LOCK", cacheKey);

            if (redisCacheService.SetNX(cacheKeyLocked))
            {
                try
                {
                    AddCacheKey(invocation, redisCacheService, parameters, svcCacheAttribute, cacheKey);
                }
                catch (Exception ex)
                {
                    LogHelper.Error(string.Format("{0}\r\n{1}", ex.Message, ex.StackTrace.ToString()));
                }
                finally
                {
                    redisCacheService.Remove(cacheKeyLocked);
                }

                return(false);
            }
            return(true);
        }