-
Notifications
You must be signed in to change notification settings - Fork 1
test/#redis #115
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
base: main
Are you sure you want to change the base?
test/#redis #115
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| package org.creditto.core_banking.global.config; | ||
|
|
||
| import org.springframework.context.annotation.Bean; | ||
| import org.springframework.context.annotation.Configuration; | ||
| import org.springframework.data.redis.connection.RedisConnectionFactory; | ||
| import org.springframework.data.redis.core.RedisTemplate; | ||
| import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer; | ||
| import org.springframework.data.redis.serializer.StringRedisSerializer; | ||
|
|
||
| @Configuration | ||
| public class RedisConfig { | ||
|
|
||
| @Bean | ||
| public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory connectionFactory) { | ||
| RedisTemplate<String, Object> template = new RedisTemplate<>(); | ||
| template.setConnectionFactory(connectionFactory); | ||
|
|
||
| // key:value | ||
| template.setKeySerializer(new StringRedisSerializer()); | ||
| template.setValueSerializer(new GenericJackson2JsonRedisSerializer()); | ||
|
|
||
| // hash key:value | ||
| template.setHashKeySerializer(new StringRedisSerializer()); | ||
| template.setHashValueSerializer((new GenericJackson2JsonRedisSerializer())); | ||
|
|
||
| return template; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,11 @@ spring: | |
| username: ${DB_USERNAME} | ||
| password: ${DB_PASSWORD} | ||
| driver-class-name: com.mysql.cj.jdbc.Driver | ||
| data: | ||
| redis: | ||
| host: localhost | ||
| port: 6379 | ||
|
Comment on lines
+11
to
+12
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Redis νΈμ€νΈμ ν¬νΈκ° host: ${REDIS_HOST:localhost}
port: ${REDIS_PORT:6379} |
||
| timeout: 2000 | ||
|
|
||
| scheduler: | ||
| remittance: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| package org.creditto.core_banking.domain.redis; | ||
|
|
||
| import org.junit.jupiter.api.Disabled; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.springframework.beans.factory.annotation.Autowired; | ||
| import org.springframework.boot.test.context.SpringBootTest; | ||
| import org.springframework.data.redis.core.RedisTemplate; | ||
|
|
||
| @Disabled | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| @SpringBootTest | ||
| public class RedisTest { | ||
|
|
||
| @Autowired | ||
| private RedisTemplate<String, Object> redisTemplate; | ||
|
|
||
| @Test | ||
| void testRedisConnection() { | ||
| String key = "test-key"; | ||
| String expectedValue = "redis"; | ||
| redisTemplate.opsForValue().set(key, expectedValue); | ||
| Object value = redisTemplate.opsForValue().get(key); | ||
| System.out.println("Redis Value: " + value); | ||
kswdot marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
kswdot marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.