diff --git a/src/main/kotlin/io/github/reactivecircus/kstreamlined/backend/KSBackendApplication.kt b/src/main/kotlin/io/github/reactivecircus/kstreamlined/backend/KSBackendApplication.kt index b581aa2..ca38927 100644 --- a/src/main/kotlin/io/github/reactivecircus/kstreamlined/backend/KSBackendApplication.kt +++ b/src/main/kotlin/io/github/reactivecircus/kstreamlined/backend/KSBackendApplication.kt @@ -2,8 +2,10 @@ package io.github.reactivecircus.kstreamlined.backend import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication +import org.springframework.scheduling.annotation.EnableScheduling @SpringBootApplication +@EnableScheduling class KSBackendApplication fun main(args: Array) { diff --git a/src/main/kotlin/io/github/reactivecircus/kstreamlined/backend/scheduling/ScheduledCacheRefresh.kt b/src/main/kotlin/io/github/reactivecircus/kstreamlined/backend/scheduling/ScheduledCacheRefresh.kt new file mode 100644 index 0000000..9de2fdd --- /dev/null +++ b/src/main/kotlin/io/github/reactivecircus/kstreamlined/backend/scheduling/ScheduledCacheRefresh.kt @@ -0,0 +1,21 @@ +package io.github.reactivecircus.kstreamlined.backend.scheduling + +import io.github.reactivecircus.kstreamlined.backend.datafetcher.FeedEntryDataFetcher +import io.github.reactivecircus.kstreamlined.backend.schema.generated.types.FeedSourceKey +import kotlinx.coroutines.runBlocking +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.scheduling.annotation.Scheduled +import org.springframework.stereotype.Component +import java.util.concurrent.TimeUnit + +@Component +class ScheduledCacheRefresh { + + @Autowired + private lateinit var feedEntryDataFetcher: FeedEntryDataFetcher + + @Scheduled(fixedDelay = 1, timeUnit = TimeUnit.HOURS) + fun refreshFeedEntryCache() = runBlocking { + feedEntryDataFetcher.feedEntries(FeedSourceKey.entries) + } +}