From 9678c7708b63f88541a7a1423902e06687cc9365 Mon Sep 17 00:00:00 2001 From: Taras Mankovski Date: Sun, 8 Jan 2017 12:52:57 -0500 Subject: [PATCH 1/2] Added password option --- README.md | 10 ++++++++++ index.js | 11 +++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 468c779..8722dff 100644 --- a/README.md +++ b/README.md @@ -50,3 +50,13 @@ let cache = new RedisCache({ } }); ``` + +You can specify Redis authentication password if your server requires it. + +```js +let cache = new RedisCache({ + host: FASTBOOT_REDIS_HOST, + port: FASTBOOT_REDIS_PORT, + password: FASTBOOT_REDIS_PASSWORD +}); +``` \ No newline at end of file diff --git a/index.js b/index.js index aa7c33e..8f7256c 100644 --- a/index.js +++ b/index.js @@ -6,10 +6,17 @@ const FIVE_MINUTES = 5 * 60; class RedisCache { constructor(options) { - let client = this.client = redis.createClient({ + + let clientOptions = { host: options.host, port: options.port - }); + }; + + if (options.password) { + clientOptions.password = options.password; + } + + let client = this.client = redis.createClient(clientOptions); this.expiration = options.expiration || FIVE_MINUTES; this.connected = false; From 76a8ad686b87acc2013bd5fa0832c4e11a4ccbd5 Mon Sep 17 00:00:00 2001 From: Hassan Abdel-Rahman Date: Sun, 28 Aug 2016 12:19:23 -0400 Subject: [PATCH 2/2] make sure to expire the same key that was added --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 8f7256c..50c75f2 100644 --- a/index.js +++ b/index.js @@ -72,7 +72,7 @@ class RedisCache { this.client.multi() .set(key, body) - .expire(path, this.expiration) + .expire(key, this.expiration) .exec(err => { if (err) { rej(err);