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 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 override BinaryRequest Build() { var request = new BinaryRequest(OpCode.Stat); if (!String.IsNullOrEmpty(this.type)) request.Key = this.type; return request; }
protected override BinaryRequest Build(string key) { var request = new BinaryRequest(OpCode.GetQ) { Key = key }; return(request); }
protected override BinaryRequest Build(string key) { var request = new BinaryRequest(OpCode.GetQ) { Key = key }; return request; }
protected override BinaryRequest Build() { var request = new BinaryRequest(OpCode.Delete) { Key = this.Key, Cas = this.Cas }; return(request); }
protected override BinaryRequest Build() { var request = new BinaryRequest(OpCode.SaslStep) { Key = this.Provider.Type, Data = new ArraySegment <byte>(this.Provider.Continue(this.continuation)) }; return(request); }
protected override BinaryRequest Build() { var request = new BinaryRequest(OpCode.Delete) { Key = this.Key, Cas = this.Cas }; return request; }
protected override BinaryRequest Build() { var request = new BinaryRequest(OpCode.SaslStep) { Key = this.Provider.Type, Data = new ArraySegment<byte>(this.Provider.Continue(this.continuation)) }; return request; }
protected override BinaryRequest Build() { // create a Sasl Start command var request = new BinaryRequest(OpCode.SaslStart) { Key = this.Provider.Type, Data = new ArraySegment<byte>(this.Provider.Authenticate()) }; return request; }
protected override BinaryRequest Build() { var request = new BinaryRequest((OpCode)this.mode) { Key = this.Key, Cas = this.Cas, Data = this.data }; return(request); }
protected override BinaryRequest Build() { var request = new BinaryRequest((OpCode)this.mode) { Key = this.Key, Cas = this.Cas, Data = this.data }; return request; }
protected override BinaryRequest Build() { // create a Sasl Start command var request = new BinaryRequest(OpCode.SaslStart) { Key = this.Provider.Type, Data = new ArraySegment <byte>(this.Provider.Authenticate()) }; return(request); }
protected override BinaryRequest Build() { var request = new BinaryRequest((OpCode)this.mode) { Key = this.Key, Cas = this.Cas }; this.UpdateExtra(request); return request; }
protected override BinaryRequest Build() { var request = new BinaryRequest((OpCode)this.mode) { Key = this.Key, Cas = this.Cas }; this.UpdateExtra(request); 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); }
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); }
protected override BinaryRequest Build() { var extra = new byte[4]; BinaryConverter.EncodeUInt32(expires, extra, 0); var request = new BinaryRequest(OpCode.Touch) { Key = this.Key, Extra = new ArraySegment <byte>(extra) }; return(request); }
protected override BinaryRequest Build() { var op = (byte)CouchbaseOpCode.Unlock; var request = new BinaryRequest(op); if (this.locator != null) { request.Reserved = (ushort)locator.GetIndex(this.Key); if (log.IsDebugEnabled) log.DebugFormat("Key {0} was mapped to {1}", this.Key, request.Reserved); } request.Key = Key; request.Cas = Cas; return request; }
protected internal override IList <ArraySegment <byte> > GetBuffer() { var keys = this.Keys; if (keys == null || keys.Count == 0) { if (log.IsWarnEnabled) { log.Warn("Empty multiget!"); } return(new ArraySegment <byte> [0]); } if (log.IsDebugEnabled) { log.DebugFormat("Building multi-get for {0} keys", keys.Count); } // map the command's correlationId to the item key, // so we can use GetQ (which only returns the item data) this.idToKey = new Dictionary <int, string>(); // get ops have 2 segments, header + key var buffers = new List <ArraySegment <byte> >(keys.Count * 2); foreach (var key in keys) { var request = this.Build(key); request.CreateBuffer(buffers); // we use this to map the responses to the keys idToKey[request.CorrelationId] = key; } // uncork the server var noop = new BinaryRequest(OpCode.NoOp); this.noopId = noop.CorrelationId; noop.CreateBuffer(buffers); return(buffers); }
protected override BinaryRequest Build() { var retval = new BinaryRequest(0x1c); retval.Key = this.Key; if (this.locator != null) { retval.Reserved = (ushort)locator.GetIndex(this.Key); if (log.IsDebugEnabled) log.DebugFormat("Key {0} was mapped to {1}", this.Key, retval.Reserved); } var extra = new byte[4]; BinaryConverter.EncodeUInt32(this.expires, extra, 0); retval.Extra = new ArraySegment<byte>(extra); return retval; }
protected internal override IList<ArraySegment<byte>> GetBuffer() { var keys = this.Keys; if (keys == null || keys.Count == 0) { if (log.IsWarnEnabled) log.Warn("Empty multiget!"); return new ArraySegment<byte>[0]; } if (log.IsDebugEnabled) log.DebugFormat("Building multi-get for {0} keys", keys.Count); // map the command's correlationId to the item key, // so we can use GetQ (which only returns the item data) this.idToKey = new Dictionary<int, string>(); // get ops have 2 segments, header + key var buffers = new List<ArraySegment<byte>>(keys.Count * 2); foreach (var key in keys) { var request = this.Build(key); request.CreateBuffer(buffers); // we use this to map the responses to the keys idToKey[request.CorrelationId] = key; } // uncork the server var noop = new BinaryRequest(OpCode.NoOp); this.noopId = noop.CorrelationId; noop.CreateBuffer(buffers); return buffers; }
protected unsafe void UpdateExtra(BinaryRequest request) { if (mode == MutationMode.Touch) { Span <byte> extra = stackalloc byte[4]; BinaryPrimitives.WriteUInt32BigEndian(extra, this.expires); request.Extra = new ArraySegment <byte>(extra.ToArray()); } else { 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); } }
protected override BinaryRequest Build() { var request = new BinaryRequest(OpCode.Flush); return(request); }
protected override BinaryRequest Build() { var request = new BinaryRequest(0x96) { Data = this.BuildBody() }; return request; }
protected override BinaryRequest Build() { var request = new BinaryRequest(OpCode.Flush); return request; }