-
Notifications
You must be signed in to change notification settings - Fork 1
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
* feat: SELECT_WORKBOOK_RECORD_CACHE 추가 * refactor: selectWorkBook 메서드 데이터 베이스 케시 설정 * feat: WorkBookCacheManager 구현 * feat: SELECT_WRITER_CACHE 추가 * feat: MemberCacheManager 구현 * feat: MemberCacheManager 적용 * refactor: 동시성을 고려한 수정 * refactor: 캐시 사이즈 수정 * refactor: 변수 이름 수정 * refactor: 복수형 이름으로 수정
- Loading branch information
1 parent
ffe27fb
commit b319fd0
Showing
5 changed files
with
115 additions
and
7 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
40 changes: 40 additions & 0 deletions
40
api-repo/src/main/kotlin/com/few/api/repo/dao/member/MemberCacheManager.kt
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,40 @@ | ||
package com.few.api.repo.dao.member | ||
|
||
import com.few.api.repo.config.LocalCacheConfig.Companion.SELECT_WRITER_CACHE | ||
import com.few.api.repo.dao.member.record.WriterRecord | ||
import org.springframework.cache.CacheManager | ||
import org.springframework.stereotype.Service | ||
import javax.cache.Cache | ||
|
||
@Suppress("UNCHECKED_CAST") | ||
@Service | ||
class MemberCacheManager( | ||
private val cacheManager: CacheManager, | ||
) { | ||
|
||
private var selectWriterCache: Cache<Any, Any> = cacheManager.getCache(SELECT_WRITER_CACHE)?.nativeCache as Cache<Any, Any> | ||
|
||
fun getAllWriterValues(): List<WriterRecord> { | ||
val values = mutableListOf<WriterRecord>() | ||
selectWriterCache.iterator().forEach { | ||
values.add(it.value as WriterRecord) | ||
} | ||
return values | ||
} | ||
|
||
fun getAllWriterValues(keys: List<Long>): List<WriterRecord> { | ||
val values = mutableListOf<WriterRecord>() | ||
keys.forEach { | ||
selectWriterCache.get(it)?.let { value -> | ||
values.add(value as WriterRecord) | ||
} | ||
} | ||
return values | ||
} | ||
|
||
fun addSelectWorkBookCache(records: List<WriterRecord>) { | ||
records.forEach { | ||
selectWriterCache.put(it.writerId, it) | ||
} | ||
} | ||
} |
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
24 changes: 24 additions & 0 deletions
24
api-repo/src/main/kotlin/com/few/api/repo/dao/workbook/WorkBookCacheManager.kt
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,24 @@ | ||
package com.few.api.repo.dao.workbook | ||
|
||
import com.few.api.repo.config.LocalCacheConfig.Companion.SELECT_WORKBOOK_RECORD_CACHE | ||
import com.few.api.repo.dao.workbook.record.SelectWorkBookRecord | ||
import org.springframework.cache.CacheManager | ||
import org.springframework.stereotype.Service | ||
import javax.cache.Cache | ||
|
||
@Suppress("UNCHECKED_CAST") | ||
@Service | ||
class WorkBookCacheManager( | ||
private val cacheManager: CacheManager, | ||
) { | ||
|
||
private var selectWorkBookCache: Cache<Any, Any> = cacheManager.getCache(SELECT_WORKBOOK_RECORD_CACHE)?.nativeCache as Cache<Any, Any> | ||
|
||
fun getAllSelectWorkBookValues(): List<SelectWorkBookRecord> { | ||
val values = mutableListOf<SelectWorkBookRecord>() | ||
selectWorkBookCache.iterator().forEach { | ||
values.add(it.value as SelectWorkBookRecord) | ||
} | ||
return values | ||
} | ||
} |
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