public bool TryTakeWriteLockAndGetData(DateTime lockTime, int lockTimeout, out object lockId, out ISessionStateItemCollection data, out int sessionTimeout) { string expectedLockId = lockTime.Ticks.ToString(); object rowDataFromRedis = null; string[] keyArgs = new string[] { Keys.LockKey, Keys.DataKey, Keys.InternalKey }; object[] valueArgs = new object[] { expectedLockId, lockTimeout }; rowDataFromRedis = redisConnection.Eval(writeLockAndGetDataScript, keyArgs, valueArgs); bool ret = false; data = null; lockId = redisConnection.GetLockId(rowDataFromRedis); sessionTimeout = redisConnection.GetSessionTimeout(rowDataFromRedis); bool isLocked = redisConnection.IsLocked(rowDataFromRedis); if (!isLocked && lockId.ToString().Equals(expectedLockId)) { ret = true; data = redisConnection.GetSessionData(rowDataFromRedis); } return(ret); }