Hello,
Is Redis connection information available on globals? I want to pass that to a server connect extension/module
Hello,
Is Redis connection information available on globals? I want to pass that to a server connect extension/module
You need to require /app/config/config.js from your module.
Also:
If you want to use environment variables you need to change core files and make sure you discard changes with GIT with every update.
lib/setup/redis.js
const config = require('./config');
if (config.redis) {
const redis = require('redis');
global.redisClient = redis.createClient(config.redis === true ? 'redis://redis' : process.env.REDIS_URL);
}
module.exports = global.redisClient;
This way I set redis to NO(unchecked) on the UI and load it from dotenv
Bummer about the core changes, looks the trio is very busy
With Redis checkbox unchecked, does it still store Express sessions on Redis? I’m guessing it won’t, because config.redis is false
It does. No problems there as it will read the global.redisClient data which was set above.
if (options.store.$type == 'redis') { // https://www.npmjs.com/package/connect-redis
const RedisStore = require('connect-redis')(session);
options.store = new RedisStore(Object.assign({
client: global.redisClient
}, options.store));
}
Just make sure you have the right config in config.js
"session": {
"store": {
"$type": "redis",
"ttl": 86400
}
}
If you deviate from core and use ENV variables you require dotenv and if not you require config.js