예제 #1
0
        public async Task ExecuteInLockAsync(string lockKey, Func <object, Task <object> > action, object state)
        {
            var redisLock = await RedisLock.AcquireAsync(_redisDatabase, GetRedisKey(lockKey), _timeOutTimeSpan, _holdDurationTimeSpan);

            try
            {
                await action(state);
            }
            finally
            {
                await redisLock.DisposeAsync();
            }
        }
예제 #2
0
        public async Task ExecuteInLockAsync(string lockKey, Action action)
        {
            var redisLock = await RedisLock.AcquireAsync(_redisDatabase, GetRedisKey(lockKey), _timeOutTimeSpan, _holdDurationTimeSpan);

            try
            {
                action();
            }
            finally
            {
                await redisLock.DisposeAsync();
            }
        }