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, *args) ⇒ Object
- #close ⇒ Object
-
#initialize(pool, *args) ⇒ Generic
constructor
A new instance of Generic.
- #read_response ⇒ Object
- #write_request(command, *args) ⇒ Object
Constructor Details
#initialize(pool, *args) ⇒ Generic
Returns a new instance of Generic.
28 29 30 31 |
# File 'lib/async/redis/context/generic.rb', line 28 def initialize(pool, *args) @pool = pool @connection = pool.acquire end |
Instance Method Details
#call(command, *args) ⇒ Object
50 51 52 53 54 |
# File 'lib/async/redis/context/generic.rb', line 50 def call(command, *args) write_request(command, *args) return read_response end |
#close ⇒ Object
33 34 35 36 37 38 |
# File 'lib/async/redis/context/generic.rb', line 33 def close if @connection @pool.release(@connection) @connection = nil end end |
#read_response ⇒ Object
44 45 46 47 48 |
# File 'lib/async/redis/context/generic.rb', line 44 def read_response @connection.flush return @connection.read_response end |
#write_request(command, *args) ⇒ Object
40 41 42 |
# File 'lib/async/redis/context/generic.rb', line 40 def write_request(command, *args) @connection.write_request([command, *args]) end |