mloughran / em-hiredis

Eventmachine redis client
MIT License
221 stars 63 forks source link

Database is not selected automatically #9

Closed marcboeker closed 12 years ago

marcboeker commented 12 years ago
redis://user:password@localhost:6379/2

Using this URI to connect to Hiredis, the database is not selected automatically. It always defaults to DB 0. Inspecting the Client object after creation, the instance variable @db has the correct value.

@db = '2'

But when I'm doing a manual select of the DB, it works like a charm.

con = EM::Hiredis.connect('redis://user:password@localhost:6379/2')
con.select('2')

Thanks Marc

mloughran commented 12 years ago

If sounds like a bug. I'm not going to have time to look into this for a while, but the following code in client.rb should mean that the database is selected. Maybe you can debug a little?

@connection.on(:connected) do
  @connected = true

  select(@db) if @db

Cheers, Martyn