-
Notifications
You must be signed in to change notification settings - Fork 1
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
๐ :: ๋ ๋์ค ์บ์ ์ ์ฉ #347
Conversation
|
||
@ReadOnlyService | ||
class GetAcceptedUsersService( | ||
private val userRepository: UserRepository, | ||
) { | ||
|
||
@Cacheable(value = ["AcceptedUser"], cacheManager = "userCacheManager") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์ฌ๋ฌ๊ฐ์ ์ํธ๋ฆฌ๊ฐ ์กด์ฌํ ์๋ ์๋ ์ํฉ์ด๋ฏ๋ก key๋ฅผ ์ง์ ํ๋ ๋ฐฉ์์ ๋ช ์ํด์ค ํ์๊ฐ ์์ด ๋ณด์ด๊ณ , ๊ฐ ์ํธ๋ฆฌ๋ง๋ค ์บ์ฑ์ ํ๋ ๊ฒ์ ๋งค์ฐ ๋นํจ์จ์ ์ด๋ฉฐ Redis์ ๋ถ๋ด์ ์ค ์ ์๋ ์์ ์ผ๋ก ๋ณด์ ๋๋ค @Cacheable์ condition ํ๋๋ฅผ ์ด์ฉํด๋ณด๋๊ฒ๋ ์ข๊ฒ ๋ค์
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2fa0c71
๋ง์ํ์ ๋๋ก ํ๋ผ๋ฏธํฐ์ ๋ฐ๋ผ ์ฌ๋ฌ๊ฐ์ ์ํธ๋ฆฌ๊ฐ ์กด์ฌํ ๊ฒ ๊ฐ์์ ๊ทธ๋์ ๊ฐ ์ํธ๋ฆฌ๋ง๋ค ์บ์ฑ์ ํ๋ ๊ฒ์ ๋นํจ์จ์ ์ด๋ผ๊ณ ์๊ฐ์ด ๋ค์ด condition์ ์ง์ ํ์ฌ ์ฒซ ์์ฒญ ์์ ๋ณด๋ด์ง๋ ๋ชจ๋ ํ์ ๋ฆฌ์คํธ๋ง ์บ์ฑํ๊ธฐ ์ํด condition ์์ฑ์ ์ถ๊ฐํ์์ด์
|
||
@TransactionalService | ||
class AcceptUserSignUpService( | ||
private val userRepository: UserRepository, | ||
private val userRoleRepository: UserRoleRepository | ||
) { | ||
|
||
@CacheEvict(value = ["AcceptedUser"], allEntries = true, cacheManager = "userCacheManager") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์์ ์ฝ๋ฉํธ์ ๋จ๊ธด key๋ฅผ ํตํด ์ํธ๋ฆฌ๋ฅผ ์ญ์ ํ๋๊ฐ ์์ ์ ํ๋๊ฒ์ด ๋ฐ๋์งํด ๋ณด์ ๋๋ค
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
๏ฟฝ์์์ ๊ฐ์ด condition์ ์ง์ ํด์ ํด๊ฒฐํ์์ต๋๋ค
@Bean | ||
@Primary | ||
fun clientCacheManager(factory: RedisConnectionFactory?): CacheManager { | ||
val cacheConfig = RedisCacheConfiguration.defaultCacheConfig() | ||
.serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(StringRedisSerializer())) | ||
.serializeValuesWith( | ||
RedisSerializationContext.SerializationPair.fromSerializer( | ||
GenericJackson2JsonRedisSerializer() | ||
) | ||
) | ||
.entryTtl(Duration.ofMinutes(10)) | ||
|
||
return RedisCacheManager | ||
.RedisCacheManagerBuilder | ||
.fromConnectionFactory(factory!!) | ||
.cacheDefaults(cacheConfig) | ||
.build() | ||
} | ||
|
||
@Bean | ||
fun userCacheManager(factory: RedisConnectionFactory?): CacheManager { | ||
val cacheConfig = RedisCacheConfiguration.defaultCacheConfig() | ||
.serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(StringRedisSerializer())) | ||
.serializeValuesWith( | ||
RedisSerializationContext.SerializationPair.fromSerializer( | ||
GenericJackson2JsonRedisSerializer() | ||
) | ||
) | ||
.entryTtl(Duration.ofMinutes(10)) | ||
|
||
return RedisCacheManager | ||
.RedisCacheManagerBuilder | ||
.fromConnectionFactory(factory!!) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์ ๊ฐ ๋ณด๊ธฐ์ ๋๋ฉ์ธ๋ณ๋ก cacheManager๋ฅผ ๋ฐ๋ก ์ฌ์ฉํ๋๋ก ์๋ํ์ ๊ฒ ๊ฐ์๋ฐ ๊ทธ๋ฌํ ์ด์ ๊ฐ ์์ผ์ค๊น์?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
๋๋ฉ์ธ๋ณ๋ก ๊ตฌ๋ถํด์ ์ฌ์ฉํ๋ฉด ๋ฐ์ดํฐ๋ฅผ ๋ณด๊ธฐ์ ํธํ ๊ฒ ๊ฐ์์ ์ฌ์ฉํ์ต๋๋ค
๋ณ ๋ค๋ฅธ ์๋ฏธ๋ ์์ต๋๋ค
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
๊ทธ๋ ๋ค๋ฉด ๊ทธ๋ฅ ๋๋ฉ์ธ๋ณ๋ก ๋๋๋๊ฒ๋ณด๋ค cacheManager๋ฅผ redisCacheManager๋ก ํต์ผํ๊ณ ์ด๋ค ๋ชฉ์ ์ ์ํด์ ์ฌ์ฉ๋๋์ง Cache ์ค์ ์ ๋ค๋ฅด๊ฒ ์ ์ฉํ๋ ์์ผ๋ก ๋ณ๊ฒฝํ๋๊ฒ ์ข์ ๊ฒ ๊ฐ์ต๋๋ค
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์ข์ ๊ฒ ๊ฐ์์ ์์ ํ๊ฒ ์ต๋๋ค
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -13,6 +14,7 @@ class DeleteClientService( | |||
private val userUtil: UserUtil, | |||
) { | |||
|
|||
@CacheEvict(value = ["Clients"], allEntries = true, cacheManager = "clientCacheManager") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์ ๊ฐ ์๊ธฐ๋ก๋ ์บ์ value๋ฅผ yml์ ์ด๋ฆ์ผ๋ก ๋ฏธ๋ฆฌ ์ ์ํด์ ์บ์ ์ ์ฅ์๊ฐ ์ฒซ ์์ฒญ ์์ ๋์ ์ผ๋ก ๋ง๋ค์ด์ง๋ ๊ฒ์ด ์๋ ์ ์ ์ผ๋ก ๋ง๋ค์ด์ง๋๋ก ํ๋๊ฒ์ด ์ข์๋ณด์ ๋๋ค
๊ทผ๋ฐ ์ด๊ฑฐ ์กฐ๊ธ๋ ์ฐพ์ ๋ณด์๊ณ ํด์ฃผ์ จ์ผ๋ฉด ํด์ ์ ๊ฐ ํ๋ ธ์ ์๋ ์์ต๋๋ค
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
d04c3c5
๋ง์ํด์ฃผ์ ๋ฐฉ๋ฒ์ผ๋ก ์์ ํด๋ณด์์ต๋๋ค ๋ง์ํ์ ๊ฑฐ๋ ๋ง๋์ง ๋ชจ๋ฅด๊ฒ ์ด์ ํ์ธํด์ฃผ์ธ์!
src/main/resources/application.yml
Outdated
type: redis | ||
cache-names: | ||
- Clients | ||
- AcceptedUser |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์ด์ ๋ณด๋ ์บ์ ์ด๋ฆ์ด AcceptedUser ๋ณด๋ค๋ ๋ณต์ํ์ธ AcceptedUsers๊ฐ ๋ ์ ์ ํด ๋ณด์ ๋๋ค
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
df5a677
์ ๋ ๊ทธ๋ฐ ๊ฒ ๊ฐ๋ค์ ์์ ํ์์ต๋๋ค
src/main/kotlin/com/msg/gauth/domain/user/service/GetAcceptedUsersService.kt
Outdated
Show resolved
Hide resolved
โฆsersService.kt Co-authored-by: ๊นํ์ค <103710151+KimTaeO@users.noreply.github.com>
src/main/kotlin/com/msg/gauth/domain/admin/service/ExcelParsingService.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/com/msg/gauth/domain/user/service/AcceptUserSignUpService.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/com/msg/gauth/domain/user/service/GetAcceptedUsersService.kt
Outdated
Show resolved
Hide resolved
โฆsersService.kt Co-authored-by: ๊นํ์ค <103710151+KimTaeO@users.noreply.github.com>
โฆgnUpService.kt Co-authored-by: ๊นํ์ค <103710151+KimTaeO@users.noreply.github.com>
โฆgService.kt Co-authored-by: ๊นํ์ค <103710151+KimTaeO@users.noreply.github.com>
๐ก ๋ฐฐ๊ฒฝ ๋ฐ ๊ฐ์
๋ฉ์ธ ํ์ด์ง์ ๋ฑ๋ก๋ ์๋น์ค(PUBLIC) ๋ฆฌ์คํธ์ ๊ด๋ฆฌ์ ํ์ด์ง์ ์ ์ ๋ฆฌ์คํธ์ ๋ ๋์ค๋ฅผ ์ด์ฉํ์ฌ ์บ์๋ฅผ ์ ์ฉํ์์ต๋๋ค.
๋ฑ๋ก๋ ์๋น์ค ์บ์ ์ ์ฉ ์
๋ฑ๋ก๋ ์๋น์ค ์บ์ ์ ์ฉ ํ
์ ์ ๋ฆฌ์คํธ ์บ์ ์ ์ฉ ์
์ ์ ๋ฆฌ์คํธ ์บ์ ์ ์ฉ ํ
Resolves: #346
๐ ์์ ๋ด์ฉ
๏ฟฝ๋ ๋์ค ์บ์์ ๋ํ ์ค์ ์ ์ถ๊ฐํ์๊ณ ์ ์ ์ ๊ดํ ์บ์๋งค๋์ ์ ์๋น์ค์ ๊ดํ ์บ์๋งค๋์ ๋ฅผ ๋ฐ๋ก ๋์ด ๊ด๋ฆฌํ๊ณ ์ ์ ๋ฆฌ์คํธ๋ฅผ ๋ถ๋ฌ์ค๋ api๋ฅผ ํธ์ถํ๋ฉด ์บ์์ ์ฌ๋ผ๊ฐ๊ณ ์ ์ ์๋ฝ api๊ฐ ํธ์ถ๋๋ฉด ์ฌ๋ผ๊ฐ ์บ์๋ ์ฌ๋ผ์ง๋๋ค.
์๋น์ค ์บ์๋ PUBLIC์ผ๋ก ๋์ด์๋ ์๋น์ค๋ฅผ ๋ฐํํ๋ api๊ฐ ํธ์ถ๋๋ฉด ์บ์์ ์ฌ๋ผ๊ฐ๊ณ ์๋น์ค์ ๊ดํ ๋ชจ๋ CUD api๊ฐ ํธ์ถ๋๋ฉด ๋ชจ๋ ์ํธ๋ฆฌ๋ ์ญ์ ๋ฉ๋๋ค.
๐โโ๏ธ ๋ฆฌ๋ทฐ๋ ธํธ
์์ง ์บ์์ ๋ํ ์ดํด๋๊ฐ ๋ถ์กฑํ์ฌ ๊ฐ์ํ๊ณ ์ฝ๋๋ฆฌ๋ทฐ ๋ถํ๋๋ฆฝ๋๋ค!
๋ฐ์ดํฐ๋ฒ ์ด์ค์ ์ด์๋ก ์ ์ ์ ๊ดํ ์บ์ ํ ์คํธ๋ฅผ ํ์ง ๋ชปํด pr์ ํ์ธํด์ฃผ์๋ฉด์ ๋ธ๋์น๋ก ์ด๋ํด์ฃผ์ ์ ํ ์คํธ ํ๋ฒ๋ง ํด์ฃผ์๋ฉด ๊ฐ์ฌํ๊ฒ ์ต๋๋ค!
24/9/3
์ ์ ๋ฆฌ์คํธ ๊ดํ ํ ์คํธ ์งํ ํ ์ด์ ์์์ ํ์ธํ์์ต๋๋ค.
โ PR ์ฒดํฌ๋ฆฌ์คํธ
.env
,๋ ธ์
,README
)"API ๊ฐ๋ฐ ์๋ฃ๋์ด์"
,"ํ๊ฒฝ๊ฐ ์ถ๊ฐ๋์์ด์"
)๐ธ ๊ธฐํ