Skip to content
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

Merged
merged 27 commits into from
Sep 18, 2024

Conversation

Umjiseung
Copy link
Contributor

@Umjiseung Umjiseung commented Sep 1, 2024

๐Ÿ’ก ๋ฐฐ๊ฒฝ ๋ฐ ๊ฐœ์š”

๋ฉ”์ธ ํŽ˜์ด์ง€์˜ ๋“ฑ๋ก๋œ ์„œ๋น„์Šค(PUBLIC) ๋ฆฌ์ŠคํŠธ์™€ ๊ด€๋ฆฌ์ž ํŽ˜์ด์ง€์˜ ์œ ์ € ๋ฆฌ์ŠคํŠธ์— ๋ ˆ๋””์Šค๋ฅผ ์ด์šฉํ•˜์—ฌ ์บ์‹œ๋ฅผ ์ ์šฉํ•˜์˜€์Šต๋‹ˆ๋‹ค.

๋“ฑ๋ก๋œ ์„œ๋น„์Šค ์บ์‹œ ์ ์šฉ ์ „
แ„‰แ…ณแ„แ…ณแ„…แ…ตแ†ซแ„‰แ…ฃแ†บ 2024-09-01 แ„‹แ…ฉแ„’แ…ฎ 11 25 10

๋“ฑ๋ก๋œ ์„œ๋น„์Šค ์บ์‹œ ์ ์šฉ ํ›„
แ„‰แ…ณแ„แ…ณแ„…แ…ตแ†ซแ„‰แ…ฃแ†บ 2024-09-01 แ„‹แ…ฉแ„’แ…ฎ 11 20 45

์œ ์ € ๋ฆฌ์ŠคํŠธ ์บ์‹œ ์ ์šฉ ์ „
แ„‰แ…ณแ„แ…ณแ„…แ…ตแ†ซแ„‰แ…ฃแ†บ 2024-09-03 แ„‹แ…ฉแ„Œแ…ฅแ†ซ 11 19 35

์œ ์ € ๋ฆฌ์ŠคํŠธ ์บ์‹œ ์ ์šฉ ํ›„
แ„‰แ…ณแ„แ…ณแ„…แ…ตแ†ซแ„‰แ…ฃแ†บ 2024-09-03 แ„‹แ…ฉแ„Œแ…ฅแ†ซ 11 19 47

Resolves: #346

๐Ÿ“ƒ ์ž‘์—…๋‚ด์šฉ

๏ฟฝ๋ ˆ๋””์Šค ์บ์‹œ์— ๋Œ€ํ•œ ์„ค์ •์„ ์ถ”๊ฐ€ํ•˜์˜€๊ณ  ์œ ์ €์— ๊ด€ํ•œ ์บ์‹œ๋งค๋‹ˆ์ €์™€ ์„œ๋น„์Šค์— ๊ด€ํ•œ ์บ์‹œ๋งค๋‹ˆ์ €๋ฅผ ๋”ฐ๋กœ ๋‘์–ด ๊ด€๋ฆฌํ•˜๊ณ  ์œ ์ € ๋ฆฌ์ŠคํŠธ๋ฅผ ๋ถˆ๋Ÿฌ์˜ค๋Š” api๋ฅผ ํ˜ธ์ถœํ•˜๋ฉด ์บ์‹œ์— ์˜ฌ๋ผ๊ฐ€๊ณ  ์œ ์ € ์ˆ˜๋ฝ api๊ฐ€ ํ˜ธ์ถœ๋˜๋ฉด ์˜ฌ๋ผ๊ฐ„ ์บ์‹œ๋Š” ์‚ฌ๋ผ์ง‘๋‹ˆ๋‹ค.

์„œ๋น„์Šค ์บ์‹œ๋Š” PUBLIC์œผ๋กœ ๋˜์–ด์žˆ๋Š” ์„œ๋น„์Šค๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋Š” api๊ฐ€ ํ˜ธ์ถœ๋˜๋ฉด ์บ์‹œ์— ์˜ฌ๋ผ๊ฐ€๊ณ  ์„œ๋น„์Šค์— ๊ด€ํ•œ ๋ชจ๋“  CUD api๊ฐ€ ํ˜ธ์ถœ๋˜๋ฉด ๋ชจ๋“  ์—”ํŠธ๋ฆฌ๋Š” ์‚ญ์ œ๋ฉ๋‹ˆ๋‹ค.

๐Ÿ™‹โ€โ™‚๏ธ ๋ฆฌ๋ทฐ๋…ธํŠธ

์•„์ง ์บ์‹œ์— ๋Œ€ํ•œ ์ดํ•ด๋„๊ฐ€ ๋ถ€์กฑํ•˜์—ฌ ๊ฐ์•ˆํ•˜๊ณ  ์ฝ”๋“œ๋ฆฌ๋ทฐ ๋ถ€ํƒ๋“œ๋ฆฝ๋‹ˆ๋‹ค!
๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์˜ ์ด์Šˆ๋กœ ์œ ์ €์— ๊ด€ํ•œ ์บ์‹œ ํ…Œ์ŠคํŠธ๋ฅผ ํ•˜์ง€ ๋ชปํ•ด pr์„ ํ™•์ธํ•ด์ฃผ์‹œ๋ฉด์„œ ๋ธŒ๋žœ์น˜๋กœ ์ด๋™ํ•ด์ฃผ์…”์„œ ํ…Œ์ŠคํŠธ ํ•œ๋ฒˆ๋งŒ ํ•ด์ฃผ์‹œ๋ฉด ๊ฐ์‚ฌํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค!

24/9/3
์œ ์ € ๋ฆฌ์ŠคํŠธ ๊ด€ํ•œ ํ…Œ์ŠคํŠธ ์ง„ํ–‰ ํ›„ ์ด์ƒ ์—†์Œ์„ ํ™•์ธํ•˜์˜€์Šต๋‹ˆ๋‹ค.

โœ… PR ์ฒดํฌ๋ฆฌ์ŠคํŠธ

ํ…œํ”Œ๋ฆฟ ์ฒดํฌ๋ฆฌ์ŠคํŠธ ๋ง๊ณ ๋„ ์ถ”๊ฐ€์ ์œผ๋กœ ํ•„์š”ํ•œ ์ฒดํฌ๋ฆฌ์ŠคํŠธ๋Š” ์ถ”๊ฐ€ํ•ด์ฃผ์„ธ์š”!

  • ์ด ์ž‘์—…์œผ๋กœ ์ธํ•ด ๋ณ€๊ฒฝ์ด ํ•„์š”ํ•œ ๋ฌธ์„œ๊ฐ€ ๋ณ€๊ฒฝ๋˜์—ˆ๋‚˜์š”? (e.g. .env, ๋…ธ์…˜, README)
  • ์ด ์ž‘์—…์„ ํ•˜๊ณ ๋‚˜์„œ ๊ณต์œ ํ•ด์•ผํ•  ํŒ€์›๋“ค์—๊ฒŒ ๊ณต์œ ๋˜์—ˆ๋‚˜์š”? (e.g. "API ๊ฐœ๋ฐœ ์™„๋ฃŒ๋์–ด์š”", "ํ™˜๊ฒฝ๊ฐ’ ์ถ”๊ฐ€๋˜์—ˆ์–ด์š”")
  • ์ž‘์—…ํ•œ ์ฝ”๋“œ๊ฐ€ ์ •์ƒ์ ์œผ๋กœ ๋™์ž‘ํ•˜๋‚˜์š”?
  • Merge ๋Œ€์ƒ ๋ธŒ๋žœ์น˜๊ฐ€ ์˜ฌ๋ฐ”๋ฅธ๊ฐ€์š”?
  • PR๊ณผ ๊ด€๋ จ ์—†๋Š” ์ž‘์—…์ด ์žˆ์ง€๋Š” ์•Š๋‚˜์š”?
  • ์ด ์ž‘์—…์œผ๋กœ ์ธํ•ด ๋ฐœ์ƒํ•œ ๋ณ€๊ฒฝ ์‚ฌํ•ญ์ด Resource ์„œ๋ฒ„์—๋„ ๋ฐ˜์˜๋˜์—ˆ๋‚˜์š”?

๐ŸŽธ ๊ธฐํƒ€

@Umjiseung Umjiseung added 2๏ธโƒฃPriority: Medium ์šฐ์„ ์ˆœ์œ„ ์ค‘ โœจ Feature ๊ธฐ๋Šฅ ๊ฐœ๋ฐœ labels Sep 1, 2024
@Umjiseung Umjiseung self-assigned this Sep 1, 2024

@ReadOnlyService
class GetAcceptedUsersService(
private val userRepository: UserRepository,
) {

@Cacheable(value = ["AcceptedUser"], cacheManager = "userCacheManager")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์—ฌ๋Ÿฌ๊ฐœ์˜ ์—”ํŠธ๋ฆฌ๊ฐ€ ์กด์žฌํ•  ์ˆ˜๋„ ์žˆ๋Š” ์ƒํ™ฉ์ด๋ฏ€๋กœ key๋ฅผ ์ง€์ •ํ•˜๋Š” ๋ฐฉ์‹์„ ๋ช…์‹œํ•ด์ค„ ํ•„์š”๊ฐ€ ์žˆ์–ด ๋ณด์ด๊ณ , ๊ฐ ์—”ํŠธ๋ฆฌ๋งˆ๋‹ค ์บ์‹ฑ์„ ํ•˜๋Š” ๊ฒƒ์€ ๋งค์šฐ ๋น„ํšจ์œจ์ ์ด๋ฉฐ Redis์— ๋ถ€๋‹ด์„ ์ค„ ์ˆ˜ ์žˆ๋Š” ์ž‘์—…์œผ๋กœ ๋ณด์ž…๋‹ˆ๋‹ค @Cacheable์˜ condition ํ•„๋“œ๋ฅผ ์ด์šฉํ•ด๋ณด๋Š”๊ฒƒ๋„ ์ข‹๊ฒ ๋„ค์š”

Copy link
Contributor Author

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")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์œ„์˜ ์ฝ”๋ฉ˜ํŠธ์— ๋‚จ๊ธด key๋ฅผ ํ†ตํ•ด ์—”ํŠธ๋ฆฌ๋ฅผ ์‚ญ์ œํ•˜๋˜๊ฐ€ ์ˆ˜์ •์„ ํ•˜๋Š”๊ฒƒ์ด ๋ฐ”๋žŒ์งํ•ด ๋ณด์ž…๋‹ˆ๋‹ค

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๏ฟฝ์œ„์—์™€ ๊ฐ™์ด condition์„ ์ง€์ •ํ•ด์„œ ํ•ด๊ฒฐํ•˜์˜€์Šต๋‹ˆ๋‹ค

Comment on lines 20 to 52
@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!!)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ œ๊ฐ€ ๋ณด๊ธฐ์—” ๋„๋ฉ”์ธ๋ณ„๋กœ cacheManager๋ฅผ ๋”ฐ๋กœ ์‚ฌ์šฉํ•˜๋„๋ก ์˜๋„ํ•˜์‹  ๊ฒƒ ๊ฐ™์€๋ฐ ๊ทธ๋Ÿฌํ•œ ์ด์œ ๊ฐ€ ์žˆ์œผ์‹ค๊นŒ์š”?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋„๋ฉ”์ธ๋ณ„๋กœ ๊ตฌ๋ถ„ํ•ด์„œ ์‚ฌ์šฉํ•˜๋ฉด ๋ฐ์ดํ„ฐ๋ฅผ ๋ณด๊ธฐ์— ํŽธํ•  ๊ฒƒ ๊ฐ™์•„์„œ ์‚ฌ์šฉํ–ˆ์Šต๋‹ˆ๋‹ค
๋ณ„ ๋‹ค๋ฅธ ์˜๋ฏธ๋Š” ์—†์Šต๋‹ˆ๋‹ค

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๊ทธ๋ ‡๋‹ค๋ฉด ๊ทธ๋ƒฅ ๋„๋ฉ”์ธ๋ณ„๋กœ ๋‚˜๋ˆ„๋Š”๊ฒƒ๋ณด๋‹ค cacheManager๋ฅผ redisCacheManager๋กœ ํ†ต์ผํ•˜๊ณ  ์–ด๋–ค ๋ชฉ์ ์— ์˜ํ•ด์„œ ์‚ฌ์šฉ๋˜๋Š”์ง€ Cache ์„ค์ •์„ ๋‹ค๋ฅด๊ฒŒ ์ ์šฉํ•˜๋Š” ์‹์œผ๋กœ ๋ณ€๊ฒฝํ•˜๋Š”๊ฒŒ ์ข‹์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ข‹์€ ๊ฒƒ ๊ฐ™์•„์š” ์ˆ˜์ •ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1e03118
4597c4b
์ˆ˜์ •ํ–ˆ์Šต๋‹ˆ๋‹ค

@@ -13,6 +14,7 @@ class DeleteClientService(
private val userUtil: UserUtil,
) {

@CacheEvict(value = ["Clients"], allEntries = true, cacheManager = "clientCacheManager")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ œ๊ฐ€ ์•Œ๊ธฐ๋กœ๋Š” ์บ์‹œ value๋ฅผ yml์— ์ด๋ฆ„์œผ๋กœ ๋ฏธ๋ฆฌ ์ •์˜ํ•ด์„œ ์บ์‹œ ์ €์žฅ์†Œ๊ฐ€ ์ฒซ ์š”์ฒญ ์‹œ์— ๋™์ ์œผ๋กœ ๋งŒ๋“ค์–ด์ง€๋Š” ๊ฒƒ์ด ์•„๋‹Œ ์ •์ ์œผ๋กœ ๋งŒ๋“ค์–ด์ง€๋„๋ก ํ•˜๋Š”๊ฒƒ์ด ์ข‹์•„๋ณด์ž…๋‹ˆ๋‹ค

๊ทผ๋ฐ ์ด๊ฑฐ ์กฐ๊ธˆ๋” ์ฐพ์•„ ๋ณด์‹œ๊ณ  ํ•ด์ฃผ์…จ์œผ๋ฉด ํ•ด์š” ์ œ๊ฐ€ ํ‹€๋ ธ์„ ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

d04c3c5
๋ง์”€ํ•ด์ฃผ์‹  ๋ฐฉ๋ฒ•์œผ๋กœ ์ˆ˜์ •ํ•ด๋ณด์•˜์Šต๋‹ˆ๋‹ค ๋ง์”€ํ•˜์‹ ๊ฑฐ๋ž‘ ๋งž๋Š”์ง€ ๋ชจ๋ฅด๊ฒ ์–ด์„œ ํ™•์ธํ•ด์ฃผ์„ธ์š”!

type: redis
cache-names:
- Clients
- AcceptedUser
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ด์ œ๋ณด๋‹ˆ ์บ์‹œ ์ด๋ฆ„์ด AcceptedUser ๋ณด๋‹ค๋Š” ๋ณต์ˆ˜ํ˜•์ธ AcceptedUsers๊ฐ€ ๋” ์ ์ ˆํ•ด ๋ณด์ž…๋‹ˆ๋‹ค

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

df5a677
์ €๋„ ๊ทธ๋Ÿฐ ๊ฒƒ ๊ฐ™๋„ค์š” ์ˆ˜์ •ํ•˜์˜€์Šต๋‹ˆ๋‹ค

Umjiseung and others added 4 commits September 18, 2024 23:28
โ€ฆ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>
@Umjiseung Umjiseung merged commit f314ecc into main Sep 18, 2024
1 check passed
@Umjiseung Umjiseung deleted the feature/346-redis-used-caching-apply branch September 18, 2024 23:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2๏ธโƒฃPriority: Medium ์šฐ์„ ์ˆœ์œ„ ์ค‘ โœจ Feature ๊ธฐ๋Šฅ ๊ฐœ๋ฐœ
Projects
None yet
Development

Successfully merging this pull request may close these issues.

๋ ˆ๋””์Šค๋ฅผ ์ด์šฉํ•œ ์บ์‹œ ์ ์šฉ
2 participants