public override void Execute(MemcachedSocket memcachedSocket) { memcachedSocket.WriteLine("stats"); string line = memcachedSocket.ReadLine(); while (line.StartsWith("STAT")) { int indexOfStatName = line.IndexOf(" ") + 1; int indexOfStatValue = line.IndexOf(" ", indexOfStatName); string name = line.Substring(indexOfStatName, indexOfStatValue - indexOfStatName); string value = line.Substring(indexOfStatValue, line.Length - indexOfStatValue); Stats.Add(new KeyValuePair<string, string>(name, value)); line = memcachedSocket.ReadLine(); } CheckResponse(line, "END"); }
public override void Execute(MemcachedSocket memcachedSocket) { memcachedSocket.WriteLine("flush_all"); memcachedSocket.Flush(); CheckResponse(memcachedSocket.ReadLine(), "OK"); }
public void AfterFlush(MemcachedSocket memcachedSocket) { string line = memcachedSocket.ReadLine(); if (line == "END") return; CheckResponseStart(line, "VALUE"); string[] splitLine = line.Split(' '); StoredObjectType objType = (StoredObjectType)int.Parse(splitLine[2]); int length = int.Parse(splitLine[3]); switch (objType) { case StoredObjectType.IntCounter: RetrievedObject = int.Parse(memcachedSocket.ReadLine().Substring(0, length)); break; case StoredObjectType.UIntCounter: RetrievedObject = uint.Parse(memcachedSocket.ReadLine().Substring(0, length)); break; case StoredObjectType.LongCounter: RetrievedObject = long.Parse(memcachedSocket.ReadLine().Substring(0, length)); break; case StoredObjectType.SerializableObject: byte[] bytes = memcachedSocket.ReadBytes(length); using (MemoryStream memoryStream = new MemoryStream(bytes)) { RetrievedObject = new BinaryFormatter().Deserialize(memoryStream); } CheckResponse(memcachedSocket.ReadLine(), ""); break; default: throw new Exception("Unexpected StoredObjectType: " + objType.ToString()); } CheckResponse(memcachedSocket.ReadLine(), "END"); }
public void AfterFlush(MemcachedSocket memcachedSocket) { string response = memcachedSocket.ReadLine(); if (response == "NOT_FOUND") { return; } uint result; if (uint.TryParse(response, out result)) { RetrievedValue = result; } else { throw new UnexpectedResponseMatchException(response, "NOT_FOUND", "<uint value>"); } }
internal string ReadResponseFromStream(MemcachedSocket memcachedSocket) { return memcachedSocket.ReadLine(); }
public void AfterFlush(MemcachedSocket memcachedSocket) { CheckResponse(memcachedSocket.ReadLine(), "STORED"); CheckResponse(memcachedSocket.ReadLine(), "DELETED"); }