Class: Async::Redis::Protocol::Selected
- Inherits:
-
Object
- Object
- Async::Redis::Protocol::Selected
- Defined in:
- lib/async/redis/protocol/selected.rb
Overview
Executes AUTH after the user has established a connection.
Defined Under Namespace
Classes: SelectionError
Instance Attribute Summary collapse
-
#index ⇒ Object
readonly
Returns the value of attribute index.
Instance Method Summary collapse
-
#client(stream) ⇒ Object
Create a new client and authenticate it.
-
#initialize(index, protocol = Async::Redis::Protocol::RESP2) ⇒ Selected
constructor
Create a new authenticated protocol.
Constructor Details
Instance Attribute Details
#index ⇒ Object (readonly)
Returns the value of attribute index.
26 27 28 |
# File 'lib/async/redis/protocol/selected.rb', line 26 def index @index end |
Instance Method Details
#client(stream) ⇒ Object
Create a new client and authenticate it.
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/async/redis/protocol/selected.rb', line 29 def client(stream) client = @protocol.client(stream) client.write_request(["SELECT", @index]) response = client.read_response if response != "OK" raise SelectionError, "Could not select database: #{response}" end return client end |