A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://socketry.github.io/async-redis/source/Async/Redis/Context/Pipeline/index.html below:

Async::Redis::Context::Pipeline

Send multiple commands without waiting for the response, instead of sending them one by one.

Definitions def initialize(pool)

Initialize a new pipeline context.

Signature
parameter pool Pool

The connection pool to use.

Implementation
def initialize(pool)
	super(pool)
	
	@count = 0
	@sync = nil
end
def flush(count = 0)

Flush responses.

Implementation
def flush(count = 0)
	while @count > count
		read_response
	end
end
def collect

Collect all pending responses.

Signature
yields {...}

Optional block to execute while collecting responses.

returns Array

Array of all responses if no block given.

Implementation
def collect
	if block_given?
		flush
		yield
	end
	
	@count.times.map{read_response}
end
def sync

Get a synchronous wrapper for this pipeline.

Signature
returns Sync

A synchronous wrapper that executes commands immediately.

Implementation
def sync
	@sync ||= Sync.new(self)
end
def write_request(*)

This method just accumulates the commands and their params.

Implementation
def write_request(*)
	super
	
	@count += 1
end
def call(command, *arguments)

This method just accumulates the commands and their params.

Implementation
def call(command, *arguments)
	write_request(command, *arguments)
	
	return nil
end
def read_response

Read a response from the pipeline.

Signature
returns Object

The next response in the pipeline.

Implementation
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.

Implementation
def 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