private List <byte[]> SendGet(IEnumerable <string> cacheKeysOrTagNames, bool isTagNames = false, string pattern = "*") { byte[] command = null; var sb = new StringBuilder(); sb.Append("get"); sb.Append(" ").Append(pattern); if (isTagNames) { sb.Append(" -t"); } using (var memoryStream = new MemoryStream()) { memoryStream.Write(sb.ToString()); foreach (var cacheKeyOrTagName in cacheKeysOrTagNames) { memoryStream.Write(cacheKeyOrTagName); } command = memoryStream.ToArray(); } // Send and receive command = _client.SendReceive(command); // Verify that we got something if (command == null || (command.Length == 1 && command[0] == 0)) { return(null); } // Get command result var commandResultParts = new List <byte[]>(); int position = 0; while (position < command.Length) { commandResultParts.Add(DacheProtocolHelper.Extract(command, ref position)); } return(commandResultParts); }
private IDictionary <string, string> SendGetPerformanceData() { byte[] command = null; var sb = new StringBuilder(); sb.Append("perf"); using (var memoryStream = new MemoryStream()) { memoryStream.Write(sb.ToString()); command = memoryStream.ToArray(); } // Send and receive command = _client.SendReceive(command); // Verify that we got something if (command == null || (command.Length == 1 && command[0] == 0)) { return(null); } // Get command result var commandResultParts = new Dictionary <string, string>(); int position = 0; while (position < command.Length) { using (var memoryStream = new MemoryStream()) { var formatter = new BinaryFormatter(); memoryStream.Write(command, 0, command.Length); memoryStream.Position = 0; commandResultParts = formatter.Deserialize(memoryStream) as Dictionary <string, string>; break; } } return(commandResultParts); }