From b7729a587c417ccccef5a949d20668d03296e282 Mon Sep 17 00:00:00 2001 From: haio Date: Tue, 15 Apr 2014 19:28:23 +0800 Subject: [PATCH 1/4] Support Chinese query --- lib/reds.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/reds.js b/lib/reds.js index 3ed33c0..7846418 100644 --- a/lib/reds.js +++ b/lib/reds.js @@ -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); }; /** From be9dd28ee1b4423235b10c93b6bd40b825e3bc11 Mon Sep 17 00:00:00 2001 From: haio Date: Mon, 21 Apr 2014 18:28:26 +0800 Subject: [PATCH 2/4] Update node_redis version to support auth --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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": "*", From 32e67fdb5a83489a310dd7dbc8f7ca67f976b464 Mon Sep 17 00:00:00 2001 From: haio Date: Mon, 21 Apr 2014 18:51:26 +0800 Subject: [PATCH 3/4] Support redis configuration --- lib/reds.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/reds.js b/lib/reds.js index 7846418..362040e 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)); }; /** From 53df8f0e91625f47fc997263cfa21b9beaf48453 Mon Sep 17 00:00:00 2001 From: haio Date: Mon, 21 Apr 2014 19:55:01 +0800 Subject: [PATCH 4/4] CerateSearch support redis options --- lib/reds.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/reds.js b/lib/reds.js index 362040e..929225f 100644 --- a/lib/reds.js +++ b/lib/reds.js @@ -66,9 +66,9 @@ exports.createClient = function(port, host){ * @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); }; /** @@ -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); + } } /**