-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
fix: 방문 데이터 최적화
- Loading branch information
Showing
26 changed files
with
182 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 0 additions & 17 deletions
17
smeem-application/src/main/java/com/smeem/application/domain/visit/Visit.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
smeem-application/src/main/java/com/smeem/application/port/output/cache/CachePort.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.smeem.application.port.output.cache; | ||
|
||
public interface CachePort { | ||
void setBit(String key, long offset, boolean value); | ||
boolean getBit(String key, long offset); | ||
} |
8 changes: 0 additions & 8 deletions
8
smeem-application/src/main/java/com/smeem/application/port/output/persistence/VisitPort.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
project(':smeem-output-cache') { | ||
dependencies { | ||
} | ||
} | ||
|
||
project(':smeem-output-cache:redis') { | ||
dependencies { | ||
implementation 'org.springframework.boot:spring-boot-starter-data-redis' | ||
} | ||
} | ||
|
||
allprojects { | ||
dependencies { | ||
implementation project(':smeem-common') | ||
implementation project(':smeem-application') | ||
|
||
implementation 'org.springframework.boot:spring-boot-starter-web' | ||
} | ||
|
||
tasks.bootJar { | ||
enabled = false | ||
} | ||
|
||
tasks.jar { | ||
enabled = true | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...m-output-cache/redis/src/main/java/com/smeem/output/cache/redis/adapter/CacheAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.smeem.output.cache.redis.adapter; | ||
|
||
import com.smeem.application.port.output.cache.CachePort; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.data.redis.core.RedisTemplate; | ||
|
||
@Configuration | ||
@RequiredArgsConstructor | ||
public class CacheAdapter implements CachePort { | ||
private final RedisTemplate<String, String> redisTemplate; | ||
|
||
@Override | ||
public void setBit(String key, long offset, boolean value) { | ||
redisTemplate.opsForValue().setBit(key, offset, value); | ||
} | ||
|
||
@Override | ||
public boolean getBit(String key, long offset) { | ||
return Boolean.TRUE.equals(redisTemplate.opsForValue().getBit(key, offset)); | ||
} | ||
} |
72 changes: 72 additions & 0 deletions
72
smeem-output-cache/redis/src/main/java/com/smeem/output/cache/redis/config/RedisConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package com.smeem.output.cache.redis.config; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
import org.springframework.cache.CacheManager; | ||
import org.springframework.cache.annotation.EnableCaching; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.data.redis.cache.RedisCacheConfiguration; | ||
import org.springframework.data.redis.cache.RedisCacheManager; | ||
import org.springframework.data.redis.connection.RedisConnectionFactory; | ||
import org.springframework.data.redis.connection.RedisPassword; | ||
import org.springframework.data.redis.connection.RedisStandaloneConfiguration; | ||
import org.springframework.data.redis.connection.lettuce.LettuceClientConfiguration; | ||
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory; | ||
import org.springframework.data.redis.core.RedisTemplate; | ||
import org.springframework.data.redis.repository.configuration.EnableRedisRepositories; | ||
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer; | ||
import org.springframework.data.redis.serializer.RedisSerializationContext; | ||
import org.springframework.data.redis.serializer.StringRedisSerializer; | ||
|
||
import java.time.Duration; | ||
|
||
@Configuration | ||
@EnableRedisRepositories | ||
@EnableCaching | ||
@EnableConfigurationProperties(RedisProperties.class) | ||
@RequiredArgsConstructor | ||
public class RedisConfig { | ||
|
||
@Bean | ||
public LettuceConnectionFactory lettuceConnectionFactory(RedisProperties redisProperties) { | ||
RedisStandaloneConfiguration redisConfig = new RedisStandaloneConfiguration(); | ||
redisConfig.setHostName(redisProperties.host()); | ||
redisConfig.setPort(redisProperties.port()); | ||
redisConfig.setPassword(RedisPassword.of(redisProperties.password())); | ||
|
||
LettuceClientConfiguration clientConfig = LettuceClientConfiguration.builder() | ||
.useSsl() | ||
.build(); | ||
|
||
return new LettuceConnectionFactory(redisConfig, clientConfig); | ||
} | ||
|
||
@Bean | ||
public <T> RedisTemplate<String, T> redisTemplate( | ||
RedisConnectionFactory redisConnectionFactory, | ||
ObjectMapper objectMapper | ||
) { | ||
RedisTemplate<String, T> redisTemplate = new RedisTemplate<>(); | ||
redisTemplate.setConnectionFactory(redisConnectionFactory); | ||
redisTemplate.setKeySerializer(new StringRedisSerializer()); | ||
redisTemplate.setValueSerializer(new GenericJackson2JsonRedisSerializer(objectMapper)); | ||
return redisTemplate; | ||
} | ||
|
||
@Bean | ||
public CacheManager cacheManager(RedisConnectionFactory redisConnectionFactory) { | ||
RedisCacheConfiguration redisCacheConfiguration = RedisCacheConfiguration.defaultCacheConfig() | ||
.entryTtl(Duration.ofDays(7)) | ||
.serializeKeysWith( | ||
RedisSerializationContext.SerializationPair.fromSerializer(new StringRedisSerializer())) | ||
.serializeValuesWith( | ||
RedisSerializationContext.SerializationPair.fromSerializer( | ||
new GenericJackson2JsonRedisSerializer())); | ||
|
||
return RedisCacheManager.builder(redisConnectionFactory) | ||
.cacheDefaults(redisCacheConfiguration) | ||
.build(); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...output-cache/redis/src/main/java/com/smeem/output/cache/redis/config/RedisProperties.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.smeem.output.cache.redis.config; | ||
|
||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
|
||
@ConfigurationProperties(prefix = "redis") | ||
public record RedisProperties( | ||
String host, | ||
int port, | ||
String password | ||
) { | ||
} |
5 changes: 5 additions & 0 deletions
5
smeem-output-cache/redis/src/main/resources/redis-config/application-dev.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
redis: | ||
host: ${REDIS_HOST} | ||
port: 6379 | ||
password: ${REDIS_PASSWORD} | ||
ssl: true |
5 changes: 5 additions & 0 deletions
5
smeem-output-cache/redis/src/main/resources/redis-config/application-local.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
redis: | ||
host: ${REDIS_HOST} | ||
port: 6379 | ||
password: ${REDIS_PASSWORD} | ||
ssl: true |
5 changes: 5 additions & 0 deletions
5
smeem-output-cache/redis/src/main/resources/redis-config/application-prod.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
redis: | ||
host: ${REDIS_HOST} | ||
port: 6379 | ||
password: ${REDIS_PASSWORD} | ||
ssl: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 0 additions & 26 deletions
26
...tence/postgresql/src/main/java/com/smeem/persistence/postgresql/adapter/VisitAdapter.java
This file was deleted.
Oops, something went wrong.
28 changes: 0 additions & 28 deletions
28
...gresql/src/main/java/com/smeem/persistence/postgresql/persistence/entity/VisitEntity.java
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
...rc/main/java/com/smeem/persistence/postgresql/persistence/repository/VisitRepository.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.