|
|
@@ -5,6 +5,7 @@ import com.izouma.nineth.service.StatisticService;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.springframework.cache.annotation.CachePut;
|
|
|
import org.springframework.cache.annotation.Cacheable;
|
|
|
+import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
@@ -47,7 +48,7 @@ public class StatisticController {
|
|
|
}
|
|
|
|
|
|
@GetMapping("/top")
|
|
|
- @Cacheable("top")
|
|
|
+ @CachePut(value = "top", key = "#month")
|
|
|
public String top(int year, int month) {
|
|
|
LocalDateTime start = LocalDateTime.of(year, month, 1, 0, 0, 0);
|
|
|
LocalDateTime end = start.plusMonths(1).minusSeconds(1);
|
|
|
@@ -62,4 +63,10 @@ public class StatisticController {
|
|
|
LocalDateTime start = LocalDateTime.of(endDate.minusDays(6), LocalTime.MIN);
|
|
|
return statisticService.top(start, LocalDateTime.of(endDate, LocalTime.MAX), 50);
|
|
|
}
|
|
|
+
|
|
|
+ @Scheduled(fixedRate = 120000)
|
|
|
+ private void clearTop() {
|
|
|
+ int monthValue = LocalDate.now().getMonthValue();
|
|
|
+ cacheService.clearTop(monthValue);
|
|
|
+ }
|
|
|
}
|