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 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; }