Exemplo n.º 1
0
 private void CreateGetCommand(Opcode cmdType, bool noreply)
 {
     string key = MemcachedEncoding.BinaryConverter.GetString(_rawData, 0, _requestHeader.KeyLength);
     GetCommand cmd = new GetCommand(cmdType);
     cmd.Keys = new string[] { key };
     cmd.NoReply = noreply;
     _command = cmd;
 }
Exemplo n.º 2
0
        public static byte[] BuildGetResponse(GetCommand command)
        {
            string key = "";
            byte[] value=new byte[0];
            uint flag=0;
            ulong cas = 0;
            BinaryResponseStatus status = BinaryResponseStatus.no_error;
            if (command.ExceptionOccured)
                status = BinaryResponseStatus.key_not_found;
            else if (command.Results.Count > 0)
            {
                cas = command.Results[0].Version;
                value = command.Results[0].Value as byte[];
                flag = command.Results[0].Flag;

                if (command.Opcode == Opcode.GetK)
                    key = command.Results[0].Key;
            }
            else
            {
                if (command.NoReply == true)
                    return null;
                status = BinaryResponseStatus.key_not_found;
            }

            byte[] flagBytes = MemcachedEncoding.BinaryConverter.GetBytes(flag);
            return BuildResposne(command.Opcode, status, command.Opaque, cas, key, value, flagBytes);
        }
Exemplo n.º 3
0
        private void CreateRetrievalCommand(string arguments, Opcode cmdType)
        {
            if (arguments == null)
            {
                CreateInvalidCommand();
                return;
            }

            string[] argumentsArray = arguments.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            if (argumentsArray.Length == 0)
            {
                _command = new InvalidCommand();
            }
            else
            {
                GetCommand getCommand = new GetCommand(cmdType);
                getCommand.Keys = argumentsArray;
                _command = getCommand;
            }
            this.State = ParserState.ReadyToDispatch;
        }