Class: Async::Redis::Client
- Inherits:
-
Object
- Object
- Async::Redis::Client
- 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
-
#endpoint ⇒ Object
readonly
Returns the value of attribute endpoint.
-
#protocol ⇒ Object
readonly
Returns the value of attribute protocol.
- #The communication protocol.(communicationprotocol.) ⇒ Object readonly
Class Method Summary collapse
-
.open(*arguments, **options, &block) ⇒ Object
Open a Redis client and optionally yield it in an async task.
Instance Method Summary collapse
-
#initialize(endpoint = Endpoint.local, protocol: endpoint.protocol, **options) ⇒ Client
constructor
Create a new Redis client.
- #The Redis endpoint.=(Redisendpoint. = (value)) ⇒ Object
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, **) @endpoint = endpoint @protocol = protocol @pool = make_pool(**) end |
Instance Attribute Details
#endpoint ⇒ Object (readonly)
Returns the value of attribute endpoint.
160 161 162 |
# File 'lib/async/redis/client.rb', line 160 def endpoint @endpoint end |
#protocol ⇒ Object (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, **, &block) client = self.new(*arguments, **) 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 |