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.
30 31 32 33 |
# File 'lib/async/redis/context/generic.rb', line 30 def initialize(pool, *arguments) @pool = pool @connection = pool.acquire end |
Instance Method Details
#call(command, *arguments) ⇒ Object
52 53 54 55 56 |
# File 'lib/async/redis/context/generic.rb', line 52 def call(command, *arguments) write_request(command, *arguments) return read_response end |
#close ⇒ Object
35 36 37 38 39 40 |
# File 'lib/async/redis/context/generic.rb', line 35 def close if @connection @pool.release(@connection) @connection = nil end end |
#read_response ⇒ Object
46 47 48 49 50 |
# File 'lib/async/redis/context/generic.rb', line 46 def read_response @connection.flush return @connection.read_response end |
#write_request(command, *arguments) ⇒ Object
42 43 44 |
# File 'lib/async/redis/context/generic.rb', line 42 def write_request(command, *arguments) @connection.write_request([command, *arguments]) end |