diff --git a/lib/reds.js b/lib/reds.js index 3ed33c0..929225f 100644 --- a/lib/reds.js +++ b/lib/reds.js @@ -53,9 +53,9 @@ var types = { * @api public */ -exports.createClient = function(){ +exports.createClient = function(port, host){ return exports.client - || (exports.client = redis.createClient()); + || (exports.client = redis.createClient(port, host)); }; /** @@ -66,9 +66,9 @@ exports.createClient = function(){ * @api public */ -exports.createSearch = function(key){ +exports.createSearch = function(key, options){ if (!key) throw new Error('createSearch() requires a redis key for namespacing'); - return new Search(key); + return new Search(key, options); }; /** @@ -80,7 +80,7 @@ exports.createSearch = function(key){ */ exports.words = function(str){ - return String(str).match(/\w+/g); + return String(str).match(/(\w|[\u4E00-\u9FA5])+/g); }; /** @@ -281,12 +281,17 @@ Query.prototype.end = function(fn){ * Initialize a new `Search` with the given `key`. * * @param {String} key + * @param {Object} redis options * @api public */ -function Search(key) { +function Search(key, options) { + options = options || {}; this.key = key; - this.client = exports.createClient(); + this.client = exports.createClient(options.port, options.host); + if (options.password) { + this.client.auth(options.password); + } } /** diff --git a/package.json b/package.json index a51e738..8e71d28 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "author": "TJ Holowaychuk ", "dependencies": { "natural": "0.1.17", - "redis": "0.7.2" + "redis": "0.10.1" }, "devDependencies": { "should": "*",