Exemple #1
0
 /// <summary>
 /// Put "QUEUED" messages at back of queue
 /// </summary>
 /// <param name="queued"></param>
 private void QueueExpectQueued()
 {
     QueuedCommands.Insert(0, new QueuedRedisOperation()
     {
         VoidReadCommand = RedisClient.ExpectQueued
     });
 }
Exemple #2
0
        public override async void SendCommands()
        {
            //compiler currently doesn't convert string[] correctly to a js string[] so make a string
            //instead and then eval it on the js side to get the string[]
            await JSExecutor.InvokeAsync <object>("addCommands", $"[{string.Join(",", QueuedCommands.Select(x => $"\"{x}\""))}]");

            QueuedCommands.Clear();
        }
Exemple #3
0
 public override void SendCommands()
 {
     if (QueuedCommands.Count > 0)
     {
         ExecuteJs(String.Join(String.Empty, QueuedCommands));
         QueuedCommands.Clear();
     }
 }
Exemple #4
0
        protected void Execute()
        {
            int count = QueuedCommands.Count;

            for (int i = 0; i < count; ++i)
            {
                var op = QueuedCommands[0];
                QueuedCommands.RemoveAt(0);
                op.Execute(RedisClient);
                QueuedCommands.Add(op);
            }
        }
        async ValueTask <bool> IRedisTransactionAsync.CommitAsync(CancellationToken token)
        {
            bool rc = true;

            try
            {
                numCommands = QueuedCommands.Count / 2;

                //insert multi command at beginning
                QueuedCommands.Insert(0, new QueuedRedisCommand
                {
                }.WithAsyncReturnCommand(VoidReturnCommandAsync: r => { Init(); return(default); })
Exemple #6
0
        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 e)
            {
                rc = false;
            }
            finally
            {
                RedisClient.Transaction = null;
                ClosePipeline();
                RedisClient.AddTypeIdsRegisteredDuringPipeline();
            }
            return(rc);
        }
Exemple #7
0
        protected async ValueTask ExecuteAsync()
        {
            int count = QueuedCommands.Count;

            for (int i = 0; i < count; ++i)
            {
                var op = QueuedCommands[0];
                QueuedCommands.RemoveAt(0);
                await op.ExecuteAsync(RedisClient).ConfigureAwait(false);

                QueuedCommands.Add(op);
            }
        }
 /// <summary>
 /// Put "QUEUED" messages at back of queue
 /// </summary>
 partial void QueueExpectQueuedAsync()
 {
     QueuedCommands.Insert(0, new QueuedRedisOperation
     {
     }.WithAsyncReadCommand(RedisClient.ExpectQueuedAsync));
 }
Exemple #9
0
 public override void QueueCommands(List <Command> commands)
 {
     QueuedCommands.Add(ConvertCommand(commands));
 }
Exemple #10
0
 public override void QueueCommands(List <Command> commands)
 {
     QueuedCommands.Add($"addCommand(\"{ConvertCommand(commands)}\");");
 }