Separate out cache + data servers

This commit is contained in:
Michael Jackson
2018-07-06 10:53:16 -07:00
parent ffde00c444
commit 8ef362ba09
12 changed files with 43 additions and 38 deletions

9
server/utils/cache.js Normal file
View File

@ -0,0 +1,9 @@
const redis = require("redis");
redis.debug_mode = process.env.DEBUG_REDIS != null;
const client = redis.createClient(
process.env.CACHE_URL || process.env.OPENREDIS_URL || "redis://localhost:6379"
);
module.exports = client;

View File

@ -1,4 +1,4 @@
const db = require("./redis");
const db = require("./cache");
/**
* A persistent cache for JSON values, using Redis.

9
server/utils/data.js Normal file
View File

@ -0,0 +1,9 @@
const redis = require("redis");
redis.debug_mode = process.env.DEBUG_REDIS != null;
const client = redis.createClient(
process.env.DATA_URL || process.env.OPENREDIS_URL || "redis://localhost:6379"
);
module.exports = client;

View File

@ -1,4 +1,4 @@
const db = require("./redis");
const db = require("./data");
function incrementCounter(counter, key, by = 1) {
return new Promise((resolve, reject) => {

View File

@ -1,12 +0,0 @@
const redis = require("redis");
redis.debug_mode = process.env.DEBUG_REDIS != null;
const redisURL =
process.env.OPENREDIS_URL ||
process.env.REDIS_URL ||
"redis://localhost:6379";
const client = redis.createClient(redisURL);
module.exports = client;