Class: Redic::Client
- Inherits:
-
Object
- Object
- Redic::Client
- Defined in:
- lib/redic/client.rb
Instance Method Summary collapse
- #connect ⇒ Object
-
#initialize(url) ⇒ Client
constructor
A new instance of Client.
- #read ⇒ Object
- #write(command) ⇒ Object
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
#connect ⇒ Object
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 |
#read ⇒ Object
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 |