コード例 #1
0
ファイル: RedisChannel.cs プロジェクト: vtortola/RedisClient
        public IRedisResults Execute <T>(String command, T parameters, CancellationToken cancel)
            where T : class
        {
            ParameterGuard.CannotBeNullOrEmpty(command, "command");
            CheckDispose();

            var plan  = _planner.Build(command);
            var setup = Pack(plan, parameters);

            using (var token = new SyncExecutionToken(setup.Item1, setup.Item2))
                using (cancel.Register(token.SetCancelled))
                {
                    try
                    {
                        Route(plan, token, cancel);
                        token.Wait(cancel);
                    }
                    finally
                    {
                        Clean();
                    }

                    AmendResults(plan, setup.Item3);
                    return(new RedisResults(setup.Item3, plan.Headers));
                }
        }
コード例 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RedisClient"/> class.
        /// </summary>
        /// <param name="endpoints">The Redis endpoints. The selected endpoint is selected in a rota basis.</param>
        /// <param name="options"><see cref="RedisClientOptions"/></param>
        public RedisClient(IPEndPoint[] endpoints, RedisClientOptions options = null)
            : this(options)
        {
            ParameterGuard.CannotBeNullOrEmpty(endpoints, "endpoints");

            _endpoints = endpoints.ToArray();

            _procedures = _options.Procedures != null?_options.Procedures.ToCollection() : ProcedureCollection.Empty;

            _proceduresInitializer = new ProcedureInitializer(_procedures, _options.Logger);

            _multiplexedCommander = new AggregatedCommandConnection <RedisCommanderConnection>(_options.MultiplexPool.CommandConnections, CommanderFactory, _options);
            _subscriptorsPool     = new ConnectionSelector <RedisSubscriberConnection>(_options.MultiplexPool.SubscriptionOptions, SubscriberFactory, _options);

            if (_options.ExclusivePool.Maximum > 0)
            {
                _exclusivePool = new ConnectionPool(_options.ExclusivePool.Minimum, _options.ExclusivePool.Maximum, CommanderFactory, _options.Logger);
            }
            else
            {
                _exclusivePool = DisabledConnectionPool.Instance;
            }

            IExecutionPlanner planner = new ExecutionPlanner(_procedures);
            _planner = _options.UseExecutionPlanCaching ? new CachingExecutionPlanner(planner) : planner;
        }
コード例 #3
0
        internal RedisNotification(String header, String subscribedKey, String publishedKey, String content)
            : this(header)
        {
            ParameterGuard.CannotBeNullOrEmpty(subscribedKey, "subscribedKey");
            ParameterGuard.CannotBeNullOrEmpty(publishedKey, "publishedKey");
            ParameterGuard.CannotBeNullOrEmpty(content, "content");

            this.SubscribedKey = subscribedKey;
            this.PublishedKey  = publishedKey;
            this.Content       = content;
        }
コード例 #4
0
ファイル: RedisChannel.cs プロジェクト: vtortola/RedisClient
        public void Dispatch <T>(String command, T parameters)
            where T : class
        {
            ParameterGuard.CannotBeNullOrEmpty(command, "command");
            CheckDispose();

            if (_heldConnection == null)
            {
                var plan  = _planner.Build(command);
                var setup = Pack(plan, parameters);

                using (var token = new NoWaitExecutionToken(setup.Item1, setup.Item2))
                    Route(plan, token, CancellationToken.None);
            }
            else
            {
                // if in the middle of transaction, it needs to wait
                // to check if the connection can be cleaned afterwards.
                Execute <T>(command, parameters, CancellationToken.None);
            }
        }
コード例 #5
0
 internal RedisClientMultipleCommandException(RESPError error, params RedisClientCommandException[] commandExceptions)
     : base(String.Format("{0}:'{1}'", error.Prefix, error.Message), new AggregateException(commandExceptions))
 {
     ParameterGuard.CannotBeNullOrEmpty(commandExceptions, "commandExceptions");
     this.InnerExceptions = commandExceptions;
 }
コード例 #6
0
 internal RedisClientMultipleCommandException(params RedisClientCommandException[] commandExceptions)
     : base("Multiple Redis command failed, please check 'InnerExceptions' property.", new AggregateException(commandExceptions))
 {
     ParameterGuard.CannotBeNullOrEmpty(commandExceptions, "commandExceptions");
     this.InnerExceptions = commandExceptions;
 }
コード例 #7
0
        internal RedisNotification(String header)
        {
            ParameterGuard.CannotBeNullOrEmpty(header, "header");

            this.Header = header;
        }