Ejemplo n.º 1
0
        void IMultiMessage.Execute(RedisConnectionBase conn, ref int currentDb)
        {
            var pending = messages;

            if (ExecutePreconditions(conn, ref currentDb))
            {
                conn.WriteRaw(this);                                                         // MULTI
                List <QueuedMessage> newlyQueued = new List <QueuedMessage>(pending.Length); // estimate same length
                for (int i = 0; i < pending.Length; i++)
                {
                    conn.WriteMessage(ref currentDb, pending[i], newlyQueued);
                }
                newlyQueued.TrimExcess();
                conn.WriteMessage(ref currentDb, Execute(newlyQueued), null);
            }
            else
            {
                // preconditions failed; ABORT
                conn.WriteMessage(ref currentDb, RedisMessage.Create(-1, RedisLiteral.UNWATCH).ExpectOk().Critical(), null);

                // even though these weren't written, we still need to mark them cancelled
                exec.Abort(pending);
                // spoof a rollback; same appearance to the caller
                exec.Complete(RedisResult.Multi(null), false);
            }
        }
Ejemplo n.º 2
0
        void IMultiMessage.Execute(RedisConnectionBase conn, ref int currentDb)
        {
            RedisMessage[] pending       = messages;
            int            estimateCount = pending.Length;

            if (ExecutePreconditions(conn, ref currentDb))
            {
                conn.WriteRaw(this); // MULTI
                var newlyQueued = new List <QueuedMessage>(pending.Length);
                for (int i = 0; i < pending.Length; i++)
                {
                    conn.WriteMessage(ref currentDb, pending[i], newlyQueued);
                }
                newlyQueued.TrimExcess();
                conn.WriteMessage(ref currentDb, Execute(newlyQueued), null);
            }
            else
            {
                // preconditions failed; ABORT
                conn.WriteMessage(ref currentDb, Create(-1, RedisLiteral.UNWATCH).ExpectOk().Critical(), null);
                exec.Complete(RedisResult.Multi(null)); // spoof a rollback; same appearance to the caller
            }
        }
Ejemplo n.º 3
0
        void IMultiMessage.Execute(RedisConnectionBase conn, ref int currentDb)
        {
            var pending = messages;

            if (ExecutePreconditions(conn, ref currentDb))
            {
                conn.WriteRaw(this); // MULTI
                List<QueuedMessage> newlyQueued = new List<QueuedMessage>(pending.Length); // estimate same length
                for (int i = 0; i < pending.Length; i++)
                {
                    conn.WriteMessage(ref currentDb, pending[i], newlyQueued);
                }
                newlyQueued.TrimExcess();
                conn.WriteMessage(ref currentDb, Execute(newlyQueued), null);
            }
            else
            {
                // preconditions failed; ABORT
                conn.WriteMessage(ref currentDb, RedisMessage.Create(-1, RedisLiteral.UNWATCH).ExpectOk().Critical(), null);

                // even though these weren't written, we still need to mark them cancelled
                exec.Abort(pending);
                // spoof a rollback; same appearance to the caller
                exec.Complete(RedisResult.Multi(null), false);
            }
        }
Ejemplo n.º 4
0
        void IMultiMessage.Execute(RedisConnectionBase conn, ref int currentDb)
        {
            RedisMessage[] pending = messages;
            int estimateCount = pending.Length;

            if (ExecutePreconditions(conn, ref currentDb))
            {
                conn.WriteRaw(this); // MULTI
                var newlyQueued = new List<QueuedMessage>(pending.Length);
                for (int i = 0; i < pending.Length; i++)
                {
                    conn.WriteMessage(ref currentDb, pending[i], newlyQueued);
                }
                newlyQueued.TrimExcess();
                conn.WriteMessage(ref currentDb, Execute(newlyQueued), null);
            }
            else
            {
                // preconditions failed; ABORT
                conn.WriteMessage(ref currentDb, Create(-1, RedisLiteral.UNWATCH).ExpectOk().Critical(), null);
                exec.Complete(RedisResult.Multi(null)); // spoof a rollback; same appearance to the caller
            }
        }