Permalink
Browse files

* FIX Redis DB selection

* Added Redis authentication
  • Loading branch information...
1 parent 97dd032 commit 9386b22315a43e476e591f13519f25283b91514b @naholyr committed Jan 16, 2011
Showing with 15 additions and 6 deletions.
  1. +3 −2 conf/common.js
  2. +12 −4 lib/url-provider/redis.js
View
@@ -2,10 +2,11 @@ exports.conf = {
port: 3000, // Server port
host: '127.0.0.1', // Listen connections from
- url_provider: 'redis', // URL provider engine
+ url_provider: 'redis', // URL provider engine
redis: {
host: '127.0.0.1',
port: 6379,
- db: '301tl', // Redis database
+ db: 3, // Redis database index
+ pw: undefined, // Redis password
},
}
View
@@ -43,11 +43,19 @@ Provider = {
open: function(callback) {
client = redis.createClient();
client.on("connect", function(err) {
- if (typeof config.redis_db != 'undefined') {
- client.select(config.db)
+ function conn(err) {
+ if (!err && typeof config.db != 'undefined') {
+ client.select(config.db, callback)
+ } else if (callback) {
+ callback(err)
+ } else if (err) {
+ throw err
+ }
}
- if (callback) {
- callback(err)
+ if (typeof config.pw != 'undefined') {
+ client.auth(config.pw, conn)
+ } else {
+ conn(err)
}
})
client.on("error", function(err) {

0 comments on commit 9386b22

Please sign in to comment.