Skip to content
Merged
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
12 changes: 9 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,18 @@ MONGODB_TEST_PATH=mongodb://localhost:27017/llv2tests

#### REDIS ####
# Redis is used for caching aggregations and can also be used as a queue driver where SQS is not available

# The URL of your Redis instance e.g. redis://127.0.0.1:6379/0
REDIS_URL=redis://127.0.0.1:6379/0

# If REDIS_URL is not set, Learning Locker uses the following 3 variables.
# The address of your Redis instance e.g. 127.0.0.1
REDIS_HOST=127.0.0.1
# REDIS_HOST=127.0.0.1
# The port where your redis instance is running e.g. 6379
REDIS_PORT=6379
# REDIS_PORT=6379
# Your Redis DB number e.g. 0
REDIS_DB=0
# REDIS_DB=0

# A prefix for each key in the Redis DB e.g. DEVELOPMENT/PROD
REDIS_PREFIX=LEARNINGLOCKER

Expand Down
7 changes: 7 additions & 0 deletions lib/connections/redis.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import defaultTo from 'lodash/defaultTo';

const DEFAULT_REDIS_PORT = 6379;

/**
* @returns {string|object} options for ioredis or sentinel
*/
export const getOptions = () => {
const eventsRepo = defaultTo(process.env.EVENTS_REPO, 'redis');
switch (eventsRepo) {
Expand All @@ -19,6 +22,9 @@ export const getOptions = () => {
return { db, password, name, sentinels };
}
default: case 'redis': {
if (process.env.REDIS_URL) {
return process.env.REDIS_URL;
}
const db = defaultTo(Number(process.env.REDIS_DB), 0);
const password = process.env.REDIS_PASSWORD;
const host = process.env.REDIS_HOST;
Expand All @@ -32,6 +38,7 @@ export const createClient = () => {
try {
const options = getOptions();
logger.silly('Creating Redis client', options);
logger.error('Creating Redis client', options);
return new Redis(options);
} catch (e) {
logger.error("Couldn't connect to redis", e);
Expand Down
17 changes: 0 additions & 17 deletions lib/connections/socketio.js

This file was deleted.