/// <summary> /// Set key to hold the string value. If key already holds a value, it is overwritten, regardless of its type. Any previous time to live associated with the key is discarded on successful SET operation. /// </summary> /// <param name="key">key</param> /// <param name="value">String value to hold</param> /// <param name="secondsToExpire">Set the specified expire time, in seconds.</param> /// <param name="miliseconds">Set the specified expire time, in milliseconds.</param> /// <param name="nxxx">NX -- Only set the key if it does not already exist. XX -- Only set the key if it already exist.</param> /// <returns>Simple string reply: OK if SET was executed correctly. Null reply: a Null Bulk Reply is returned if the SET operation was not performed becase the user specified the NX or XX option but the condition was not met.</returns> public RedisBuffer SET(string key, string value, int secondsToExpire, int miliseconds, NXXX nxxx) { const byte parameterCount = ASCIITable.Six; redisBuffer.Length = SETDescriptor.Length + CalcSizeOfBuffer(iddisio.CMD_SET, key, value, iddisio.PAR_SET_EX, iddisio.PAR_SET_PX) + CalcSizeOfBuffer(secondsToExpire, miliseconds) + NXXXLength; redisBuffer.CopyFrom(SETDescriptor, 0, 0, SETDescriptorLength); redisBuffer.WriteByte(parameterCount, 1); var i = BulkString(redisBuffer, SETDescriptor.Length, iddisio.CMD_SET, key, value, iddisio.PAR_SET_EX); i = BulkString(redisBuffer, i, secondsToExpire); i = BulkString(redisBuffer, i, iddisio.PAR_SET_PX); i = BulkString(redisBuffer, i, miliseconds); BulkString(redisBuffer, i, NXBuffers.Values[(int)nxxx].Item2); return redisBuffer; }
/// <summary> /// Set key to hold the string value. If key already holds a value, it is overwritten, regardless of its type. Any previous time to live associated with the key is discarded on successful SET operation. /// </summary> /// <param name="key">key</param> /// <param name="value">String value to hold</param> /// <param name="nxxx">NX -- Only set the key if it does not already exist. XX -- Only set the key if it already exist.</param> /// <returns>Simple string reply: OK if SET was executed correctly. Null reply: a Null Bulk Reply is returned if the SET operation was not performed becase the user specified the NX or XX option but the condition was not met.</returns> public RedisBuffer SET(string key, string value, NXXX nxxx) { const byte parameterCount = ASCIITable.Four; redisBuffer.Length = SETDescriptor.Length + NXXXLength + CalcSizeOfBuffer(iddisio.CMD_SET, key, value); redisBuffer.CopyFrom(SETDescriptor, 0, 0, SETDescriptorLength); redisBuffer.WriteByte(parameterCount, 1); var i = BulkString(redisBuffer, SETDescriptor.Length, iddisio.CMD_SET); i = BulkString(redisBuffer, i, key); i = BulkString(redisBuffer, i, value); BulkString(redisBuffer, i, NXBuffers.Values[(int)nxxx].Item2); return redisBuffer; }