Sha256: 1cea2a4d07eec38c55f64a565b906961104ca9576916d8adac866fc044735d46
Contents?: true
Size: 1.17 KB
Versions: 1
Compression:
Stored size: 1.17 KB
Contents
# frozen_string_literal: true require 'socket' require 'timeout' module Dalli module Protocol ## # Manages the buffer for responses from memcached. ## class ResponseBuffer def initialize(io_source, response_processor) @io_source = io_source @response_processor = response_processor end def read @buffer << @io_source.read_nonblock end # Attempts to process a single response from the buffer. Starts # by advancing the buffer to the specified start position def process_single_response(start_position = 0) advance(start_position) @response_processor.getk_response_from_buffer(@buffer) end # Advances the internal response buffer by bytes_to_advance # bytes. The def advance(bytes_to_advance) @buffer = @buffer[bytes_to_advance..-1] end # Resets the internal buffer to an empty state, # so that we're ready to read pipelined responses def reset @buffer = +'' end # Clear the internal response buffer def clear @buffer = nil end def completed? @buffer.nil? end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dalli-3.1.0 | lib/dalli/protocol/response_buffer.rb |