Class: Async::Redis::Client

Inherits:
Object
  • Object
show all
Includes:
Methods, Protocol::Redis::Methods
Defined in:
lib/async/redis/client.rb

Overview

A Redis client that provides connection pooling and context management.

Defined Under Namespace

Modules: Methods

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Methods

#call, #close, #pipeline, #psubscribe, #ssubscribe, #subscribe, #transaction

Constructor Details

#initialize(endpoint = Endpoint.local, protocol: endpoint.protocol, **options) ⇒ Client

Create a new Redis client.



152
153
154
155
156
157
# File 'lib/async/redis/client.rb', line 152

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

Instance Attribute Details

#endpointObject (readonly)

Returns the value of attribute endpoint.



160
161
162
# File 'lib/async/redis/client.rb', line 160

def endpoint
  @endpoint
end

#protocolObject (readonly)

Returns the value of attribute protocol.



163
164
165
# File 'lib/async/redis/client.rb', line 163

def protocol
  @protocol
end

#The communication protocol.(communicationprotocol.) ⇒ Object (readonly)



163
# File 'lib/async/redis/client.rb', line 163

attr :protocol

Class Method Details

.open(*arguments, **options, &block) ⇒ Object

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



171
172
173
174
175
176
177
178
179
180
181
182
183
# File 'lib/async/redis/client.rb', line 171

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

Instance Method Details

#The Redis endpoint.=(Redisendpoint. = (value)) ⇒ Object



160
# File 'lib/async/redis/client.rb', line 160

attr :endpoint