Class: Async::Redis::Client
- Inherits:
-
Object
- Object
- Async::Redis::Client
- Defined in:
- lib/async/redis/client.rb
Instance Attribute Summary collapse
-
#endpoint ⇒ Object
readonly
Returns the value of attribute endpoint.
-
#protocol ⇒ Object
readonly
Returns the value of attribute protocol.
Class Method Summary collapse
Instance Method Summary collapse
- #call(*arguments) ⇒ Object
- #close ⇒ Object
-
#initialize(endpoint = Redis.local_endpoint, protocol = Protocol::RESP, **options) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(endpoint = Redis.local_endpoint, protocol = Protocol::RESP, **options) ⇒ Client
Returns a new instance of Client.
33 34 35 36 37 38 |
# File 'lib/async/redis/client.rb', line 33 def initialize(endpoint = Redis.local_endpoint, protocol = Protocol::RESP, **) @endpoint = endpoint @protocol = protocol @connections = connect(**) end |
Instance Attribute Details
#endpoint ⇒ Object (readonly)
Returns the value of attribute endpoint.
40 41 42 |
# File 'lib/async/redis/client.rb', line 40 def endpoint @endpoint end |
#protocol ⇒ Object (readonly)
Returns the value of attribute protocol.
41 42 43 |
# File 'lib/async/redis/client.rb', line 41 def protocol @protocol end |
Class Method Details
.open(*args, &block) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/async/redis/client.rb', line 43 def self.open(*args, &block) client = self.new(*args) return client unless block_given? begin yield client ensure client.close end end |
Instance Method Details
#call(*arguments) ⇒ Object
59 60 61 62 63 64 |
# File 'lib/async/redis/client.rb', line 59 def call(*arguments) @connections.acquire do |connection| connection.write_request(arguments) return connection.read_response end end |
#close ⇒ Object
55 56 57 |
# File 'lib/async/redis/client.rb', line 55 def close @connections.close end |