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, *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

#closeObject



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_responseObject



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