添加 Redis是否enabled的配置处理

This commit is contained in:
tone
2024-09-26 13:55:06 +08:00
parent 9bbd87af0e
commit 82bfb826b2
2 changed files with 6 additions and 0 deletions

View File

@@ -12,6 +12,7 @@ const config = {
password: '' password: ''
}, },
redis: { redis: {
enable: false,
host: 'localhost', host: 'localhost',
port: 6379, port: 6379,
password: '' // localhost password: '' // localhost

View File

@@ -7,6 +7,11 @@ class _RedisConnection {
private logger = new Logger('Redis') private logger = new Logger('Redis')
constructor() { constructor() {
if (!config.redis.enable) {
this.logger.info('Database is disabled, initialization terminated');
return;
}
try { try {
this.pool = new Redis({ this.pool = new Redis({
port: config.redis.port, port: config.redis.port,