protected override BinaryRequest Build() { OpCode op; switch (this.mode) { case StoreMode.Add: op = OpCode.Add; break; case StoreMode.Set: op = OpCode.Set; break; case StoreMode.Replace: op = OpCode.Replace; break; default: throw new ArgumentOutOfRangeException("mode", mode + " is not supported"); } var extra = new byte[8]; BinaryConverter.EncodeUInt32((uint)this.value.Flags, extra, 0); BinaryConverter.EncodeUInt32(expires, extra, 4); var request = new BinaryRequest(op) { Key = this.Key, Cas = this.Cas, Extra = new ArraySegment <byte>(extra), Data = this.value.Data }; return(request); }
protected unsafe void UpdateExtra(BinaryRequest request) { byte[] extra = new byte[20]; fixed(byte *buffer = extra) { BinaryConverter.EncodeUInt64(this.delta, buffer, 0); BinaryConverter.EncodeUInt64(this.defaultValue, buffer, 8); BinaryConverter.EncodeUInt32(this.expires, buffer, 16); } request.Extra = new ArraySegment <byte>(extra); }