Class: Redic::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/redic/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ Client

Returns a new instance of Client.



6
7
8
9
10
# File 'lib/redic/client.rb', line 6

def initialize(url)
  @uri = URI.parse(url)
  @connection = nil
  @semaphore = Mutex.new
end

Instance Method Details

#connectObject



20
21
22
23
24
25
26
# File 'lib/redic/client.rb', line 20

def connect
  establish_connection unless connected?

  @semaphore.synchronize do
    yield
  end
end

#readObject



12
13
14
# File 'lib/redic/client.rb', line 12

def read
  @connection.read
end

#write(command) ⇒ Object



16
17
18
# File 'lib/redic/client.rb', line 16

def write(command)
  @connection.write(command)
end