(db: HnDatabase, cache: HnCache, feedService: FeedService)
| 11 | const FIFTEEN_MINUTES = 1000 * 60 * 15; |
| 12 | |
| 13 | export function warmCache(db: HnDatabase, cache: HnCache, feedService: FeedService): void { |
| 14 | // Fetch the front pages |
| 15 | feedService.getForType(FeedType.TOP, 30, 0); |
| 16 | feedService.getForType(FeedType.NEW, 30, 0); |
| 17 | |
| 18 | setTimeout(() => warmCache(db, cache, feedService), FIFTEEN_MINUTES); |
| 19 | } |
| 20 | |
| 21 | function rebuildFeed(db: HnDatabase, cache: HnCache, feedType: FeedType): void { |
| 22 | setTimeout(() => rebuildFeed(db, cache, feedType), 1000 * 60 * 15, feedType); |