Skip to content

Commit

Permalink
feat(#53): converted common CacheType classes java to kotlin
Browse files Browse the repository at this point in the history
  • Loading branch information
KimDoubleB committed Jan 17, 2023
1 parent e03631d commit 11ebfb9
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 36 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package site.archive.common.cache

enum class CacheType(val key: String, val expireAfterWrite: Int, val maximumSize: Int) {

BANNERS(CacheInfo.BANNERS, CacheInfo.BANNERS_GET_EXPIRE_TIME, CacheInfo.BANNERS_CACHE_SIZE),
ARCHIVE_COMMUNITIES(CacheInfo.ARCHIVE_COMMUNITIES, CacheInfo.ARCHIVE_COMMUNITIES_GET_EXPIRE_TIME, CacheInfo.ARCHIVE_COMMUNITIES_CACHE_SIZE)
;

class CacheInfo {
companion object {
const val BANNERS: String = "banners"
const val BANNERS_GET_EXPIRE_TIME: Int = 3_600
const val BANNERS_CACHE_SIZE: Int = 1

const val ARCHIVE_COMMUNITIES: String = "archive-communities"
const val ARCHIVE_COMMUNITIES_GET_EXPIRE_TIME: Int = 30
const val ARCHIVE_COMMUNITIES_CACHE_SIZE: Int = 200
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public KeyGenerator keyGenerator() {

private List<CaffeineCache> caches() {
return Arrays.stream(CacheType.values())
.map(cache -> new CaffeineCache(cache.getName(),
.map(cache -> new CaffeineCache(cache.getKey(),
Caffeine.newBuilder()
.expireAfterWrite(cache.getExpireAfterWrite(), TimeUnit.SECONDS)
.maximumSize(cache.getMaximumSize())
Expand Down

0 comments on commit 11ebfb9

Please sign in to comment.