Enable setting up Redis with URL

This commit is contained in:
Henri Bergius 2012-04-10 15:47:11 +02:00
parent 87a8172b82
commit 24e051b1e9
1 changed files with 11 additions and 1 deletions

View File

@ -8,6 +8,16 @@ var redis = safeRequire('redis');
exports.initialize = function initializeSchema(schema, callback) {
if (!redis) return;
if (schema.settings.url) {
var url = require('url');
var redisUrl = url.parse(schema.settings.url);
var redisAuth = redisUrl.auth.split(':');
schema.settings.host = redisUrl.hostname;
schema.settings.port = redisUrl.port;
schema.settings.db = redisAuth[0];
schema.settings.password = redisAuth[1];
}
schema.client = redis.createClient(
schema.settings.port,
schema.settings.host,
@ -361,7 +371,7 @@ function applyFilter(filter) {
}
});
return pass;
}
};
function test(example, value) {
if (typeof value === 'string' && example && example.constructor.name === 'RegExp') {