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.



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

#closeObject



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_responseObject



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