class Dalli::Protocol::Base

def pipelined_get_interleaved(keys, chunk_size, results)

Populates the provided results hash with any responses drained during send.
This prevents socket buffer deadlock when sending many keys.
For large batches, interleave writing requests with draining responses.
def pipelined_get_interleaved(keys, chunk_size, results)
  # Initialize the response buffer for draining during send phase
  response_buffer.ensure_ready
  keys.each_slice(chunk_size) do |chunk|
    # Build and write this chunk of requests
    req = +''
    chunk.each do |key|
      req << quiet_get_request(key)
    end
    write(req)
    @connection_manager.flush
    # Drain any available responses directly into results hash
    drain_pipeline_responses(results)
  end
end