示例#1
0
        internal RESPCommand[] Bind <T>(T parameters = null) where T : class
        {
            var result = new RESPCommand[_binders.Count];

            for (var i = 0; i < _binders.Count; i++)
            {
                result[i] = _binders[i].Bind(parameters);
            }

            return(result);
        }
        private RESPCommand BuildResponse(String header, IEnumerable <String> keys)
        {
            if (keys.Count() == 0)
            {
                this.ToString();
            }

            var response = new RESPCommand(new RESPCommandLiteral(header), true);

            foreach (var key in keys)
            {
                response.Add(new RESPCommandLiteral(key));
            }
            return(response);
        }
        private RESPCommand GenerateLoadCommand(String digest)
        {
            ProcedureDefinition procedure;

            if (!_procedures.TryGetByDigest(digest, out procedure))
            {
                throw new RedisClientParsingException("Script with digest '" + digest + "' does not exist.");
            }

            var array = new RESPCommand(new RESPCommandLiteral("SCRIPT"), false);

            array.Add(new RESPCommandLiteral("load"));
            array.Add(new RESPCommandLiteral(procedure.Body));
            return(array);
        }
        private Boolean ShouldLoadScripts(SocketWriter writer)
        {
            if (_procedures.Digests.Any())
            {
                var array = new RESPCommand(new RESPCommandLiteral("SCRIPT"), false);
                array.Add(new RESPCommandLiteral("exists"));
                foreach (var digest in _procedures.Digests)
                {
                    _logger.Info("Checking existence of script digest {0}...", digest);
                    array.Add(new RESPCommandLiteral(digest));
                }

                array.WriteTo(writer);
                writer.Flush();
                return(true);
            }
            return(false);
        }
 internal void AddCommand(RESPCommand command)
 {
     _commands.Add(command);
 }