Add Redis DB logging
Some checks failed
Deploy App / docker (ubuntu-latest, 2.44.0) (push) Failing after 39s
Some checks failed
Deploy App / docker (ubuntu-latest, 2.44.0) (push) Failing after 39s
This commit is contained in:
parent
e9e6999adc
commit
5b80d41992
@ -677,6 +677,7 @@
|
|||||||
package me.braydon.mc.config;
|
package me.braydon.mc.config;
|
||||||
|
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
@ -688,30 +689,31 @@ import org.springframework.data.redis.core.RedisTemplate;
|
|||||||
* @author Braydon
|
* @author Braydon
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
|
@Log4j2(topic = "Redis")
|
||||||
public class RedisConfig {
|
public class RedisConfig {
|
||||||
/**
|
/**
|
||||||
* The Redis server host.
|
* The Redis server host.
|
||||||
*/
|
*/
|
||||||
@Value("${spring.data.redis.host}")
|
@Value("${spring.data.redis.host}")
|
||||||
private String redisHost;
|
private String host;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Redis server port.
|
* The Redis server port.
|
||||||
*/
|
*/
|
||||||
@Value("${spring.data.redis.port}")
|
@Value("${spring.data.redis.port}")
|
||||||
private int redisPort;
|
private int port;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Redis database index.
|
* The Redis database index.
|
||||||
*/
|
*/
|
||||||
@Value("${spring.data.redis.database}")
|
@Value("${spring.data.redis.database}")
|
||||||
private int redisDatabase;
|
private int database;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The optional Redis password.
|
* The optional Redis password.
|
||||||
*/
|
*/
|
||||||
@Value("${spring.data.redis.auth}")
|
@Value("${spring.data.redis.auth}")
|
||||||
private String redisAuth;
|
private String auth;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build the config to use for Redis.
|
* Build the config to use for Redis.
|
||||||
@ -735,10 +737,12 @@ public class RedisConfig {
|
|||||||
*/
|
*/
|
||||||
@Bean @NonNull
|
@Bean @NonNull
|
||||||
public JedisConnectionFactory jedisConnectionFactory() {
|
public JedisConnectionFactory jedisConnectionFactory() {
|
||||||
RedisStandaloneConfiguration config = new RedisStandaloneConfiguration(redisHost, redisPort);
|
log.info("Connecting to Redis at {}:{}/{}", host, port, database);
|
||||||
config.setDatabase(redisDatabase);
|
RedisStandaloneConfiguration config = new RedisStandaloneConfiguration(host, port);
|
||||||
if (!redisAuth.trim().isEmpty()) { // Auth with our provided password
|
config.setDatabase(database);
|
||||||
config.setPassword(redisAuth);
|
if (!auth.trim().isEmpty()) { // Auth with our provided password
|
||||||
|
log.info("Using auth...");
|
||||||
|
config.setPassword(auth);
|
||||||
}
|
}
|
||||||
return new JedisConnectionFactory(config);
|
return new JedisConnectionFactory(config);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user