Skip to content

Commit

Permalink
add support for store/redis options.url
Browse files Browse the repository at this point in the history
  • Loading branch information
kitsonk committed Nov 26, 2012
1 parent dc82225 commit e16310d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions store/redis.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ var convertNodeAsyncFunction = require('promised-io/promise').convertNodeAsyncFu
defer = require('promised-io/promise').defer,
jsArray = require('rql/js-array'),
JSONExt = require('../util/json-ext'),
redis = require('redis');
redis = require('redis'),
url = require('url');

var RQ = require('rql/parser');
//RQ.converters['default'] = exports.converters.auto;
Expand Down Expand Up @@ -44,7 +45,14 @@ exports.Redis = function(options){
var schema;

// connect to DB
var db = redis.createClient();//dbOptions.port, dbOptions.host, {});
var db;
if(options.url){
var redisUrl = url.parse(options.url);
db = redis.createClient(redisUrl.port, redisUrl.hostname);
redis.auth(redisUrl.auth.split(":")[1]);
}else{
db = redis.createClient();//dbOptions.port, dbOptions.host, {});
}
var ready = defer();
db.addListener('ready', function(){
ready.resolve();
Expand Down

0 comments on commit e16310d

Please sign in to comment.