コード例 #1
0
ファイル: RedisTransaction.cs プロジェクト: hablan/Mainline
        public bool Replay()
        {
            bool rc = true;

            try
            {
                Execute();

                //receive expected results
                foreach (var queuedCommand in QueuedCommands)
                {
                    queuedCommand.ProcessResult();
                }
            }
            catch (RedisTransactionFailedException e)
            {
                rc = false;
            }
            finally
            {
                RedisClient.Transaction = null;
                ClosePipeline();
                RedisClient.AddTypeIdsRegisteredDuringPipeline();
            }
            return(rc);
        }
コード例 #2
0
ファイル: RedisTransaction.cs プロジェクト: hablan/Mainline
        public bool Commit()
        {
            bool rc = true;

            try
            {
                numCommands = QueuedCommands.Count / 2;

                //insert multi command at beginning
                QueuedCommands.Insert(0, new QueuedRedisCommand {
                    VoidReturnCommand = r => Init(),
                    VoidReadCommand   = RedisClient.ExpectOk,
                });

                //the first half of the responses will be "QUEUED",
                // so insert reading of multiline after these responses
                QueuedCommands.Insert(numCommands + 1, new QueuedRedisOperation {
                    IntReadCommand       = RedisClient.ReadMultiDataResultCount,
                    OnSuccessIntCallback = handleMultiDataResultCount
                });

                // add Exec command at end (not queued)
                QueuedCommands.Add(new RedisCommand {
                    VoidReturnCommand = r => Exec()
                });

                //execute transaction
                Exec();

                //receive expected results
                foreach (var queuedCommand in QueuedCommands)
                {
                    queuedCommand.ProcessResult();
                }
            }
            catch (RedisTransactionFailedException)
            {
                rc = false;
            }
            finally
            {
                RedisClient.Transaction = null;
                ClosePipeline();
                RedisClient.AddTypeIdsRegisteredDuringPipeline();
            }
            return(rc);
        }
コード例 #3
0
        public void Flush()
        {
            try
            {
                // flush send buffers
                RedisClient.FlushSendBuffer();

                //receive expected results
                foreach (var queuedCommand in QueuedCommands)
                {
                    queuedCommand.ProcessResult();
                }
            }
            finally
            {
                ClosePipeline();
                RedisClient.AddTypeIdsRegisteredDuringPipeline();
            }
        }