Skip to content

Commit

Permalink
♻️ refactor: refactor Redis4j configs #2
Browse files Browse the repository at this point in the history
  • Loading branch information
pnguyen215 committed Jul 14, 2024
1 parent f65ad2d commit 010c0e1
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
Binary file modified libs/unify4j-v1.0.0.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;
import org.unify4j.model.enums.IconType;

@Component
@ConditionalOnProperty(
Expand All @@ -27,20 +28,20 @@ public Redis4jStartupConfig(Redis4jStatusConfig config) {
@Override
public void run(ApplicationArguments args) throws Exception {
if (config.isConnected()) {
logger.info("\uD83D\uDFE2 Redis4j startup, connected Redis Server successfully");
logger.info("{} Redis4j startup, connected Redis Server successfully", IconType.SUCCESS.getCode());
} else {
logger.error("\uD83D\uDD34 Redis4j startup, unable to connect to Redis Server");
logger.error("{} Redis4j startup, unable to connect to Redis Server", IconType.ERROR.getCode());
return;
}
if (config.isDispatchAvailable()) {
logger.info("\uD83D\uDFE2 Redis4j startup, RedisTemplate<String, Object> created successfully");
logger.info("{} Redis4j startup, RedisTemplate<String, Object> created successfully", IconType.SUCCESS.getCode());
} else {
logger.error("\uD83D\uDD34 Redis4j startup, unable to create RedisTemplate<String, Object>");
logger.error("{} Redis4j startup, unable to create RedisTemplate<String, Object>", IconType.ERROR.getCode());
}
if (config.isStringDispatchAvailable()) {
logger.info("\uD83D\uDFE2 Redis4j startup, StringRedisTemplate created successfully");
logger.info("{} Redis4j startup, StringRedisTemplate created successfully", IconType.SUCCESS.getCode());
} else {
logger.error("\uD83D\uDD34 Redis4j startup, unable to create StringRedisTemplate");
logger.error("{} Redis4j startup, unable to create StringRedisTemplate", IconType.ERROR.getCode());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public void setSharedNativeConnection(boolean sharedNativeConnection) {

@Override
public String toString() {
return String.format("Redis4j { enabled: %s, debugging: %s, test_on_borrow: %s, test_on_return: %s, test_while_idle: %s, block_when_exhausted: %s, num_tests_per_eviction_run: %d, min_evict_idle_duration: %s, duration_between_eviction_runs: %s, execution_command_timeout: %s, shared_native_connection: %s }",
enabled, debugging, testOnBorrow, testOnReturn, testWhileIdle, blockWhenExhausted, numTestsPerEvictionRun, minEvictIdleDuration, durationBetweenEvictionRuns, executionCommandTimeout, sharedNativeConnection);
return String.format("Redis4j { enabled: %s, debugging: %s, test_on_borrow: %s, test_on_return: %s, test_while_idle: %s, block_when_exhausted: %s, num_tests_per_eviction_run: %d, duration_between_eviction_runs: %s, execution_command_timeout: %s, shared_native_connection: %s }",
enabled, debugging, testOnBorrow, testOnReturn, testWhileIdle, blockWhenExhausted, numTestsPerEvictionRun, durationBetweenEvictionRuns, executionCommandTimeout, sharedNativeConnection);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.springframework.stereotype.Service;
import org.unify4j.common.Object4j;
import org.unify4j.common.String4j;
import org.unify4j.model.enums.IconType;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;
Expand Down Expand Up @@ -302,7 +303,7 @@ public boolean isConnected(RedisConnectionFactory factory) {
try {
String status = factory.getConnection().ping();
if (this.isDebugging()) {
logger.info("Verifying Redis Server ping: {}", status);
logger.info("{} Verifying Redis Server ping: {}", IconType.DEBUG.getCode(), status);
}
return String4j.isNotEmpty(status);
} catch (Exception e) {
Expand Down

0 comments on commit 010c0e1

Please sign in to comment.