Skip to content

Commit

Permalink
📦 dependency: add Redis4j dependency #2 #4
Browse files Browse the repository at this point in the history
  • Loading branch information
pnguyen215 committed Jul 14, 2024
1 parent 76c4579 commit a7a2afc
Show file tree
Hide file tree
Showing 13 changed files with 142 additions and 1 deletion.
14 changes: 14 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//file:noinspection SpellCheckingInspection
//file:noinspection VulnerableLibrariesLocal
buildscript {
repositories {
// Use Maven Central for resolving dependencies.
Expand Down Expand Up @@ -227,6 +228,19 @@ dependencies {
// in Spring applications. It allows developers to manage transactions declarative or programmatically,
// ensuring data consistency and integrity across various transactional operations.
implementation 'org.springframework:spring-tx:5.3.25'
// The "spring-data-redis" library, version 2.7.8, is a Spring Data module that provides easy configuration and access to Redis from Spring applications,
// offering comprehensive support for Redis operations, including connection management, RedisTemplate, and repository support for Spring Data.
implementation group: 'org.springframework.data', name: 'spring-data-redis', version: '2.7.8'
// The "spring-integration-redis" library, version 5.5.20, is a Spring Integration module that provides support for Redis-based messaging,
// enabling integration with Redis to send and receive messages, as well as leveraging Redis Pub/Sub capabilities within Spring applications.
// Using runtimeOnly to ensure this dependency is only included at runtime.
runtimeOnly group: 'org.springframework.integration', name: 'spring-integration-redis', version: '5.5.20'
// The "lettuce-core" library, version 6.2.3.RELEASE, is a powerful and thread-safe Redis client for Java,
// providing asynchronous, synchronous, and reactive API support to efficiently interact with Redis servers.
implementation group: 'io.lettuce', name: 'lettuce-core', version: '6.2.3.RELEASE'
// The "jedis" library, version 5.1.3, is a simple and feature-rich Java client for Redis,
// providing synchronous and asynchronous communication with Redis servers to perform various operations and transactions.
implementation group: 'redis.clients', name: 'jedis', version: '5.1.3'
}

tasks.named('test') {
Expand Down
1 change: 1 addition & 0 deletions gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ ng:
- source: "libs/unify4j-v1.0.0.jar"
- source: "libs/force4j-v1.0.0.jar"
- source: "libs/botwrap4j-v1.0.0.jar"
- source: "libs/redis4j-v1.0.0.jar"
Binary file added libs/redis4j-v1.0.0.jar
Binary file not shown.
Binary file modified libs/unify4j-v1.0.0.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion src/main/java/com/suit4j/app/AppApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

@SuppressWarnings({"SpellCheckingInspection"})
@SpringBootApplication
@ComponentScan(basePackages = {"com.suit4j.app", "org.force4j", "org.botwrap4j"})
@ComponentScan(basePackages = {"com.suit4j.app", "org.force4j", "org.botwrap4j", "org.redis4j"})
public class AppApplication {

public static void main(String[] args) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.suit4j.app.controllers;

import com.suit4j.app.services.CommonService;
import org.force4j.common.Force4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
Expand All @@ -11,6 +13,12 @@
@RestController
@RequestMapping(value = "/api/v1/common")
public class CommonController extends BaseController {
protected final CommonService commonService;

@Autowired
public CommonController(CommonService commonService) {
this.commonService = commonService;
}

@GetMapping("/health")
public @ResponseBody ResponseEntity<?> inform() {
Expand Down
Empty file.
4 changes: 4 additions & 0 deletions src/main/java/com/suit4j/app/services/CommonService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.suit4j.app.services;

public interface CommonService {
}
Empty file.
12 changes: 12 additions & 0 deletions src/main/java/com/suit4j/app/services/impl/CommonServiceImpl.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.suit4j.app.services.impl;

import com.suit4j.app.services.CommonService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

@SuppressWarnings({"FieldCanBeLocal", "DuplcatedCode"})
@Service
public class CommonServiceImpl implements CommonService {
protected static final Logger logger = LoggerFactory.getLogger(CommonServiceImpl.class);
}
34 changes: 34 additions & 0 deletions src/main/resources/application-dev.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,41 @@
# ################################
# Spring Redis4J Config
# 2024-06-16 10:48:54
# ################################
spring:
# noinspection SpellCheckingInspection
redis4j: # Redis4J specific configuration
enabled: false # Toggle to enable or disable Redis4J
debugging: false # Toggle debugging for Redis4J
test_on_borrow: true # Test the connection on borrowing from the pool
test_on_return: true # Test the connection on returning to the pool
test_while_idle: true # Test the connection while idle in the pool
block_when_exhausted: true # Block when the connection pool is exhausted
shared_native_connection: true # Enable sharing of native connections across multiple clients
num_tests_per_eviction_run: 3 # Number of tests to run on eviction
duration_between_eviction_runs: 30s # Time between eviction runs
# The maximum amount of time a Redis command (or operation) can take before it is considered to have timed out.
# This timeout ensures that if a Redis command execution exceeds this duration,
# the client library will abort the operation and throw a timeout exception.
execution_command_timeout: 100ms
redis: # Configuration for the Redis connection
database: 0 # The database index to use (default is 0)
host: 127.0.0.1 # The host where the Redis server is running
port: 6379 # The port on which the Redis server is listening
password: "****" # Optional password to authenticate with Redis (if required)
timeout: 2000ms # The timeout value for connecting to Redis
jedis: # Configuration for connection pooling with Jedis
pool:
max-active: 8 # Maximum number of connections in the Jedis pool
max-idle: 8 # Maximum number of idle connections in the Jedis pool
min-idle: 0 # Minimum number of idle connections in the Jedis pool
max-wait: -1ms # Maximum wait time for a connection from the Jedis pool

# ################################
# Spring BotWrap4j Config
# 2024-06-16 10:48:54
# ################################
---
spring:
# noinspection SpellCheckingInspection
botwrap4j:
Expand Down
34 changes: 34 additions & 0 deletions src/main/resources/application-local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,40 @@ spring:
- org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration # disable the DataSource autoconfiguration
- org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration # disable the Security autoconfiguration

# ################################
# Spring Redis4J Config
# 2024-06-16 10:48:54
# ################################
---
spring:
# noinspection SpellCheckingInspection
redis4j: # Redis4J specific configuration
enabled: false # Toggle to enable or disable Redis4J
debugging: true # Toggle debugging for Redis4J
test_on_borrow: true # Test the connection on borrowing from the pool
test_on_return: true # Test the connection on returning to the pool
test_while_idle: true # Test the connection while idle in the pool
block_when_exhausted: true # Block when the connection pool is exhausted
shared_native_connection: true # Enable sharing of native connections across multiple clients
num_tests_per_eviction_run: 3 # Number of tests to run on eviction
duration_between_eviction_runs: 30s # Time between eviction runs
# The maximum amount of time a Redis command (or operation) can take before it is considered to have timed out.
# This timeout ensures that if a Redis command execution exceeds this duration,
# the client library will abort the operation and throw a timeout exception.
execution_command_timeout: 100ms
redis: # Configuration for the Redis connection
database: 0 # The database index to use (default is 0)
host: 127.0.0.1 # The host where the Redis server is running
port: 6379 # The port on which the Redis server is listening
password: "****" # Optional password to authenticate with Redis (if required)
timeout: 2000ms # The timeout value for connecting to Redis
jedis: # Configuration for connection pooling with Jedis
pool:
max-active: 8 # Maximum number of connections in the Jedis pool
max-idle: 8 # Maximum number of idle connections in the Jedis pool
min-idle: 0 # Minimum number of idle connections in the Jedis pool
max-wait: -1ms # Maximum wait time for a connection from the Jedis pool

# ################################
# Spring BotWrap4j Config
# 2024-06-16 10:48:54
Expand Down
34 changes: 34 additions & 0 deletions src/main/resources/application-prod.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,41 @@
# ################################
# Spring Redis4J Config
# 2024-06-16 10:48:54
# ################################
spring:
# noinspection SpellCheckingInspection
redis4j: # Redis4J specific configuration
enabled: false # Toggle to enable or disable Redis4J
debugging: false # Toggle debugging for Redis4J
test_on_borrow: true # Test the connection on borrowing from the pool
test_on_return: true # Test the connection on returning to the pool
test_while_idle: true # Test the connection while idle in the pool
block_when_exhausted: true # Block when the connection pool is exhausted
shared_native_connection: true # Enable sharing of native connections across multiple clients
num_tests_per_eviction_run: 3 # Number of tests to run on eviction
duration_between_eviction_runs: 30s # Time between eviction runs
# The maximum amount of time a Redis command (or operation) can take before it is considered to have timed out.
# This timeout ensures that if a Redis command execution exceeds this duration,
# the client library will abort the operation and throw a timeout exception.
execution_command_timeout: 100ms
redis: # Configuration for the Redis connection
database: 0 # The database index to use (default is 0)
host: 127.0.0.1 # The host where the Redis server is running
port: 6379 # The port on which the Redis server is listening
password: "****" # Optional password to authenticate with Redis (if required)
timeout: 2000ms # The timeout value for connecting to Redis
jedis: # Configuration for connection pooling with Jedis
pool:
max-active: 8 # Maximum number of connections in the Jedis pool
max-idle: 8 # Maximum number of idle connections in the Jedis pool
min-idle: 0 # Minimum number of idle connections in the Jedis pool
max-wait: -1ms # Maximum wait time for a connection from the Jedis pool

# ################################
# Spring BotWrap4j Config
# 2024-06-16 10:48:54
# ################################
---
spring:
# noinspection SpellCheckingInspection
botwrap4j:
Expand Down

0 comments on commit a7a2afc

Please sign in to comment.