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/Client/index.html below:

Async::Redis::Client

A Redis client that provides connection pooling and context management.

Definitions def initialize(endpoint = Endpoint.local, protocol: endpoint.protocol, **options)

Create a new Redis client.

Signature
parameter endpoint Endpoint

The Redis endpoint to connect to.

parameter protocol Protocol

The protocol to use for communication.

parameter options Hash

Additional options for the connection pool.

Implementation
def initialize(endpoint = Endpoint.local, protocol: endpoint.protocol, **options)
	@endpoint = endpoint
	@protocol = protocol
	
	@pool = make_pool(**options)
end
attr :endpoint Signature
attribute Endpoint

The Redis endpoint.

attr :protocol Signature
attribute Protocol

The communication protocol.

def self.open(*arguments, **options, &block)

Open a Redis client and optionally yield it in an async task.

Signature
yields {|client, task| ...}

If a block is given, yield the client in an async task.

parameter client Client

The Redis client instance.

parameter task Async::Task

The async task.

returns Client

The client if no block provided.

returns Object

The result of the block if block given.

Implementation
def self.open(*arguments, **options, &block)
	client = self.new(*arguments, **options)
	
	return client unless block_given?
	
	Async do |task|
		begin
			yield client, task
		ensure
			client.close
		end
	end.wait
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