Sha256: b2ced4fc708c5aa24df1e3ef3300a2e2e4eb4a184123461f2d889305980fa6d8

Contents?: true

Size: 807 Bytes

Versions: 5

Compression:

Stored size: 807 Bytes

Contents

# frozen_string_literal: true

# Released under the MIT License.
# Copyright, 2019, by Mikael Henriksson.
# Copyright, 2019-2023, by Samuel Williams.

require 'protocol/redis/methods'

module Async
	module Redis
		module Context
			class Generic
				def initialize(pool, *arguments)
					@pool = pool
					@connection = pool.acquire
				end
				
				def close
					if @connection
						@pool.release(@connection)
						@connection = nil
					end
				end
				
				def write_request(command, *arguments)
					@connection.write_request([command, *arguments])
				end
				
				def read_response
					@connection.flush
					
					return @connection.read_response
				end
				
				def call(command, *arguments)
					write_request(command, *arguments)
					
					return read_response
				end
			end
		end
	end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
async-redis-0.10.1 lib/async/redis/context/generic.rb
async-redis-0.10.0 lib/async/redis/context/generic.rb
async-redis-0.9.0 lib/async/redis/context/generic.rb
async-redis-0.8.1 lib/async/redis/context/generic.rb
async-redis-0.8.0 lib/async/redis/context/generic.rb