Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
```
13 changes: 10 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -65,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);
Expand Down