internal ExecutionPlan(IList <CommandBinder> binders) { Contract.Assert(binders.Any(), "Execution plan needs a list of binders, one per command line."); _binders = binders; Headers = binders.Select(l => l.Header.Value).ToArray(); IsTransaction = Headers.Contains("MULTI", StringComparer.Ordinal); HasScripts = Headers.Contains("EVALSHA", StringComparer.Ordinal); ContextOperation = ExecutionContextOperation.Parse(Headers); }
internal static ExecutionContextOperation Parse(String[] headers) { var op = new ExecutionContextOperation(); foreach (var header in headers) { switch (header) { case "WATCH": op.OpensWatch = true; break; case "UNWATCH": op.ClosesWatch = true; op.OpensWatch = false; break; case "MULTI": op.OpensTransaction = true; break; case "EXEC": case "DISCARD": op.ClosesTransaction = true; op.ClosesWatch = true; op.OpensTransaction = false; op.OpensWatch = false; break; case "BLPOP": case "BRPOP": case "BRPOPLPUSH": if (!op.OpensTransaction) // blocking commands inside transactions { op.HasBlockingCommand = true; // behaves as non blocking } break; } } return(op); }
internal void Apply(ExecutionContextOperation next) { IsTransactionOngoing = (IsTransactionOngoing && !next.ClosesTransaction) || next.OpensTransaction; IsWatchOnGoing = (IsWatchOnGoing && !next.ClosesWatch) || next.OpensWatch; }