Class: Async::Redis::Context::Generic

Inherits:
Object
  • Object
show all
Defined in:
lib/async/redis/context/generic.rb

Direct Known Subclasses

Pipeline, Subscribe

Instance Method Summary collapse

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

#closeObject



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_responseObject



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