Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BC-6460 Remove redis-node package #4890

Merged
merged 16 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
1 change: 0 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@
"prom-client": "^13.1.0",
"qs": "^6.9.7",
"read-chunk": "^3.0.0",
"redis": "^4.6.13",
"reflect-metadata": "^0.1.13",
"request-promise-core": "^1.1.4",
"request-promise-native": "^1.0.3",
Expand Down
10 changes: 2 additions & 8 deletions src/utils/redis.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { promisify } = require('util');
const redis = require('redis');
const Redis = require('ioredis');
const { Configuration } = require('@hpi-schul-cloud/commons');

const { GeneralError } = require('../errors');
Expand All @@ -10,19 +10,13 @@ let redisClient = false;
async function initializeRedisClient() {
if (Configuration.has('REDIS_URI')) {
try {
redisClient = redis.createClient({
url: Configuration.get('REDIS_URI'),
// Legacy mode is needed for compatibility with v4, see https://github.com/redis/node-redis/blob/HEAD/docs/v3-to-v4.md#legacy-mode
legacyMode: true,
});
redisClient = new Redis(Configuration.get('REDIS_URI'));

// The error event must be handled, otherwise the app crashes on redis connection errors.
// This is due to basic NodeJS behavior: https://nodejs.org/api/events.html#error-events
redisClient.on('error', (err) => {
logger.error('Redis client error', err);
});

await redisClient.connect();
} catch (err) {
throw new GeneralError('Redis connection failed!', err);
}
Expand Down
Loading