Class: Async::Redis::Context::Generic
- Inherits:
-
Object
- Object
- Async::Redis::Context::Generic
- Defined in:
- lib/async/redis/context/generic.rb
Instance Method Summary collapse
- #call(command, *arguments) ⇒ Object
- #close ⇒ Object
-
#initialize(pool, *arguments) ⇒ Generic
constructor
A new instance of Generic.
- #read_response ⇒ Object
- #write_request(command, *arguments) ⇒ Object
Constructor Details
#initialize(pool, *arguments) ⇒ Generic
Returns a new instance of Generic.
13 14 15 16 |
# File 'lib/async/redis/context/generic.rb', line 13 def initialize(pool, *arguments) @pool = pool @connection = pool.acquire end |
Instance Method Details
#call(command, *arguments) ⇒ Object
35 36 37 38 39 |
# File 'lib/async/redis/context/generic.rb', line 35 def call(command, *arguments) write_request(command, *arguments) return read_response end |
#close ⇒ Object
18 19 20 21 22 23 |
# File 'lib/async/redis/context/generic.rb', line 18 def close if @connection @pool.release(@connection) @connection = nil end end |
#read_response ⇒ Object
29 30 31 32 33 |
# File 'lib/async/redis/context/generic.rb', line 29 def read_response @connection.flush return @connection.read_response end |
#write_request(command, *arguments) ⇒ Object
25 26 27 |
# File 'lib/async/redis/context/generic.rb', line 25 def write_request(command, *arguments) @connection.write_request([command, *arguments]) end |