diff --git a/app/src/main/kotlin/io/sakurasou/plugins/Cache.kt b/app/src/main/kotlin/io/sakurasou/plugins/Cache.kt index 1fc4be7f..5adffb88 100644 --- a/app/src/main/kotlin/io/sakurasou/plugins/Cache.kt +++ b/app/src/main/kotlin/io/sakurasou/plugins/Cache.kt @@ -2,6 +2,7 @@ package io.sakurasou.plugins import com.ucasoft.ktor.simpleCache.SimpleCache import com.ucasoft.ktor.simpleMemoryCache.memoryCache +import com.ucasoft.ktor.simpleRedisCache.redisCache import io.ktor.server.application.* import kotlin.time.Duration.Companion.seconds @@ -11,15 +12,16 @@ import kotlin.time.Duration.Companion.seconds */ fun Application.configureCache(host: String, port: String) { install(SimpleCache) { - memoryCache { - invalidateAt = 10.seconds + if (host != "disabled") { + redisCache { + invalidateAt = 10.seconds + this.host = host + this.port = port.toInt() + } + } else { + memoryCache { + invalidateAt = 10.seconds + } } } - // install(SimpleCache) { - // redisCache { - // invalidateAt = 10.seconds - // host = "localhost" - // port = 6379 - // } - // } } \ No newline at end of file diff --git a/app/src/main/resources/application.yaml b/app/src/main/resources/application.yaml index 3f3b7c7b..9bd0b34f 100644 --- a/app/src/main/resources/application.yaml +++ b/app/src/main/resources/application.yaml @@ -10,8 +10,8 @@ ktor: password: $DATABASE_PASSWORD cache: redis: - host: $REDIS_HOST - port: $REDIS_PORT + host: "$REDIS_HOST:disable" + port: "$REDIS_PORT:6379" deployment: port: 8080 watch: