Exemplo n.º 1
0
        public async Task <IRedisResults> ExecuteAsync <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 AsyncExecutionToken(setup.Item1, setup.Item2))
                using (cancel.Register(token.SetCancelled))
                {
                    try
                    {
                        Route(plan, token, cancel);
                        await token.Completion.ConfigureAwait(false);
                    }
                    finally
                    {
                        Clean();
                    }

                    AmendResults(plan, setup.Item3);
                    return(new RedisResults(setup.Item3, plan.Headers));
                }
        }
        public ExecutionPlan Build(String command)
        {
            Contract.Assert(!String.IsNullOrWhiteSpace(command), "Calling to build command with an empty string.");

            return(_cache.GetOrAdd(command, cmd => _inner.Build(cmd)));
        }