コード例 #1
0
ファイル: GetStats.cs プロジェクト: davelondon/dontstayin
		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");
		}
コード例 #2
0
ファイル: Flush.cs プロジェクト: davelondon/dontstayin
		public override void Execute(MemcachedSocket memcachedSocket)
		{
			memcachedSocket.WriteLine("flush_all");
			memcachedSocket.Flush();

			CheckResponse(memcachedSocket.ReadLine(), "OK");
		}
コード例 #3
0
ファイル: Get.cs プロジェクト: davelondon/dontstayin
		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");
		}
コード例 #4
0
ファイル: Increment.cs プロジェクト: davelondon/dontstayin
		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>");
			}
		}
コード例 #5
0
		internal string ReadResponseFromStream(MemcachedSocket memcachedSocket)
		{
			return memcachedSocket.ReadLine();
		}
コード例 #6
0
		public void AfterFlush(MemcachedSocket memcachedSocket)
		{
			CheckResponse(memcachedSocket.ReadLine(), "STORED");
			CheckResponse(memcachedSocket.ReadLine(), "DELETED");
		}