Skip to content
Browse files

[api] Add an option to select redis database

  • Loading branch information...
1 parent a8c6ea2 commit 36fa0590ebf1e8df193e8a4618234335ba2033a8 @pksunkara pksunkara committed with
Showing with 4 additions and 1 deletion.
  1. +1 −1 README.md
  2. +3 −0 lib/nconf-redis.js
View
2 README.md
@@ -32,7 +32,7 @@ The Redis engine also has an in-memory cache with a default TTL of one hour. To
//
require('nconf-redis');
- nconf.use('redis', { host: 'localhost', port: 6379, ttl: 60 * 60 * 1000 });
+ nconf.use('redis', { host: 'localhost', port: 6379, ttl: 60 * 60 * 1000, db: 0 });
```
#### Author: [Charlie Robbins](http://www.nodejitsu.com)
View
3 lib/nconf-redis.js
@@ -27,10 +27,13 @@ var Redis = exports.Redis = function (options) {
this.namespace = options.namespace || 'nconf';
this.host = options.host || 'localhost';
this.port = options.port || 6379;
+ this.db = options.db || 0;
this.ttl = options.ttl || 60 * 60 * 1000;
this.cache = new nconf.stores.Memory();
this.redis = redis.createClient(options.port, options.host);
+ this.redis.select(this.db);
+
if (options.auth) {
this.redis.auth(options.auth);
}

0 comments on commit 36fa059

Please sign in to comment.
Something went wrong with that request. Please try again.