예제 #1
0
 public void CreateStatsCommand()
 {
     string argument = null;
     if (_requestHeader.KeyLength > 0)
         argument = MemcachedEncoding.BinaryConverter.GetString(_rawData, 0, _requestHeader.KeyLength);
     _command = new StatsCommand(argument);
 }
예제 #2
0
        public static byte[] BuildStatsResponse(StatsCommand command)
        {
            DataStream stream = new DataStream();
            Hashtable stats= command.OperationResult.Value as Hashtable;
            IDictionaryEnumerator ie = stats.GetEnumerator();

            string key = "";
            byte [] value = null;
            while (ie.MoveNext())
            {
                key = ie.Key as string;
                value = MemcachedEncoding.BinaryConverter.GetBytes(ie.Value as string);
                stream.Write(BuildResposne(command.Opcode, BinaryResponseStatus.no_error, command.Opaque, 0, key, value, null));
            }
            
            stream.Write(BuildResposne(command.Opcode, BinaryResponseStatus.no_error, command.Opaque, 0, null, null, null));
            return stream.ReadAll();
        }
예제 #3
0
        private void CreateStatsCommand(string arguments)
        {
            if (string.IsNullOrEmpty(arguments))
            {
                _command = new StatsCommand();
                this.State = ParserState.ReadyToDispatch;
                return;
            }

            string[] argumentsArray;
            argumentsArray = arguments.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            switch (argumentsArray[0])
            {
                case "settings":
                case "items":
                case "sizes":
                case "slabs":
                    _command = new StatsCommand(argumentsArray[0]);
                    this.State = ParserState.ReadyToDispatch;
                    break;
                default:
                    CreateInvalidCommand();
                    break;
            }
        }