Send multiple commands without waiting for the response, instead of sending them one by one.
Definitionsdef initialize(pool)
Initialize a new pipeline context.
Signaturepool
Pool
The connection pool to use.
def initialize(pool)
super(pool)
@count = 0
@sync = nil
end
def flush(count = 0)
Flush responses.
Implementationdef flush(count = 0)
while @count > count
read_response
end
end
def collect
Collect all pending responses.
Signature{...}
Optional block to execute while collecting responses.
Array
Array of all responses if no block given.
def collect
if block_given?
flush
yield
end
@count.times.map{read_response}
end
def sync
Get a synchronous wrapper for this pipeline.
SignatureSync
A synchronous wrapper that executes commands immediately.
def sync
@sync ||= Sync.new(self)
end
def write_request(*)
This method just accumulates the commands and their params.
Implementationdef write_request(*)
super
@count += 1
end
def call(command, *arguments)
This method just accumulates the commands and their params.
Implementationdef call(command, *arguments)
write_request(command, *arguments)
return nil
end
def read_response
Read a response from the pipeline.
SignatureObject
The next response in the pipeline.
def read_response
if @count > 0
@count -= 1
super
else
raise RuntimeError, "No more responses available!"
end
end
def close
Close the pipeline and flush all pending responses.
Implementationdef close
flush
ensure
super
end
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4