Skip to content

Commit

Permalink
feat: support REDIS_PASSWORD env variable (#280). Thanks to @lanphan!
Browse files Browse the repository at this point in the history
  • Loading branch information
lanphan authored and paveltiunov committed Dec 1, 2019
1 parent 441807e commit 5172745
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
4 changes: 2 additions & 2 deletions docs/Cube.js-Backend/Deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ Production Cube.js servers can be accessed only with [REST API](rest-api) and Cu
### Redis

Also, Cube.js requires [Redis](https://redis.io/), in-memory data structure store, to run in production.
It uses it for query caching and queue.
Set `REDIS_URL` environment variable to provide Cube.js with Redis connection.
It uses Redis for query caching and queue.
Set `REDIS_URL` environment variable to provide Cube.js with Redis connection. In case your Redis instance has password, please set password via `REDIS_PASSWORD` environment variable.
Make sure, your Redis allows at least 15 concurrent connections.
Set `REDIS_TLS` env variable to `true` if you want to enable secure connection.

Expand Down
15 changes: 9 additions & 6 deletions packages/cubejs-query-orchestrator/orchestrator/RedisFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@ const { promisify } = require('util');
module.exports = function createRedisClient(url) {
redis.Multi.prototype.execAsync = promisify(redis.Multi.prototype.exec);

let options;
let options = {
url,
};

if (process.env.REDIS_TLS === 'true') {
options = {
url,
tls: {}
};
options.tls = {};
}

const client = redis.createClient(options || url);
if (process.env.REDIS_PASSWORD) {
options.password = process.env.REDIS_PASSWORD;
}

const client = redis.createClient(options);

['brpop', 'del', 'get', 'hget', 'rpop', 'set', 'zadd', 'zrange', 'zrangebyscore', 'keys'].forEach(
k => {
Expand Down

0 comments on commit 5172745

Please sign in to comment.