Skip to content

Commit

Permalink
Scheduled cache refresh.
Browse files Browse the repository at this point in the history
  • Loading branch information
ychescale9 committed Nov 25, 2023
1 parent ceaa918 commit f0e8ba6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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)
}
}

0 comments on commit f0e8ba6

Please sign in to comment.