Esempio n. 1
0
		public static void FinishCurrent(PooledSocket socket)
		{
			string response = socket.ReadResponse();

			if (String.Compare(response, "END", StringComparison.Ordinal) != 0)
				throw new Exception("No END was received.");
		}
Esempio n. 2
0
		public override void Dispose()
		{
			GC.SuppressFinalize(this);

			if (this.socket != null)
			{
				((IDisposable)this.socket).Dispose();
				this.socket = null;
			}

			base.Dispose();
		}
Esempio n. 3
0
		public static GetResponse ReadItem(PooledSocket socket)
		{
			string description = socket.ReadResponse();

			if (String.Compare(description, "END", StringComparison.Ordinal) == 0)
				return null;

			if (description.Length < 6 || String.Compare(description, 0, "VALUE ", 0, 6, StringComparison.Ordinal) != 0)
				throw new Exception("No VALUE response received.\r\n" + description);

			ulong cas = 0;
			string[] parts = description.Split(' ');

			// response is:
			// VALUE <key> <flags> <bytes> [<cas unique>]
			// 0     1     2       3       4
			//
			// cas only exists in 1.2.4+
			//
			if (parts.Length == 5)
			{
				if (!UInt64.TryParse(parts[4], out cas))
					throw new Exception("Invalid CAS VALUE received.");

			}
			else if (parts.Length < 4)
			{
				throw new Exception("Invalid VALUE response received: " + description);
			}

			ushort flags = UInt16.Parse(parts[2], System.Globalization.CultureInfo.InvariantCulture);
			int length = Int32.Parse(parts[3], System.Globalization.CultureInfo.InvariantCulture);

			byte[] allData = new byte[length];
			byte[] eod = new byte[2];

			socket.Read(allData, 0, length);
			socket.Read(eod, 0, 2); // data is terminated by \r\n

			GetResponse retval = new GetResponse(parts[1], flags, cas, allData);

			if (log.IsDebugEnabled)
				log.DebugFormat("Received value. Data type: {0}, size: {1}.", retval.Item.Flag, retval.Item.Data.Count);

			return retval;
		}
Esempio n. 4
0
		protected ItemOperation(string key,PooledSocket socket)
			: base()
		{
			this.key = key;
			this.socket = socket;
		}
Esempio n. 5
0
		public SetOperation(String key, Object value, PooledSocket socket)
			: base(key, socket)
		{
			this.value = value;
		}
Esempio n. 6
0
		public GetOperation(String key, PooledSocket socket)
			: base(key, socket)
		{

		}
Esempio n. 7
0
		public DeleteOperation(String key, PooledSocket socket) 
			: base(key, socket) 
		{ }