nu7hatch / aclatraz

Flexible access control mechanism!
MIT License
110 stars 6 forks source link

Unable to connect to redis due to malformed options hash #2

Closed chikamichi closed 14 years ago

chikamichi commented 14 years ago

Hi,

The latest version of the redis gem requires an option hash to be provided to Redis.new. Currently, Aclatraz pass a string or a hash. The documentation gives several example:

    #   Aclatraz.init :redis, "redis://localhost:6379/0"
    #   Aclatraz.init :tokyocabinet, "./permissions.tch"
    #   Aclatraz.init MyCustomDatastore, :option => 1 # ...

I fixed my failures by editing the call and using:

    #@backend = ::Redis.new(*args) # the current way
    @backend = ::Redis.new(:url => args.first) # my way to please redis wrapper

but this is just a hot-fix. I guess one should either, smart-guess options based on class inspection and/or, or enforce a hash interface (:host => "…", :option1 => :foobar, …). The latter option, despite being a little bit verbose, would ensure consistency and abstraction, as several db backends are or will be supported.

btw, awesome gem! Thank you :)

nu7hatch commented 14 years ago

Hi,

The init method is pretty flexible and you can give anything as second parameter. I've just released 0.1.2 version with support for passing connection objects also. Check out the wiki page:

http://github.com/nu7hatch/aclatraz/wiki/Redis-store

... there are described few ways to configure the redis store

Cheers!

chikamichi commented 14 years ago

Well, in fact, I already tried that in the mean time ;) Thank you. A side question: I guess using several databases is not really favored by the Redis team, instead the recommandation would be to use namespaces. I did not have the time to check which approach you've been promoting in aclatraz, but would there be a way to define a namespace key for aclatraz to use? Maybe directly in the Redis.new options?

nu7hatch commented 14 years ago

Hmm, imo in this case it's better to use separate Redis database for aclatraz (or separate bucket in Riak). But i'll consider adding some prefix or namespace option to configuration.