1
0

feat: 增加接口缓存

This commit is contained in:
2025-10-11 16:24:28 +08:00
parent b0c2530e63
commit b9a02194e2
3 changed files with 48 additions and 0 deletions

View File

@@ -15,6 +15,7 @@ import java.time.LocalDate;
import java.util.List;
import java.util.Optional;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
@@ -34,6 +35,7 @@ public class StockService extends SimpleServiceSupport<Stock> {
this.dailyRepository = dailyRepository;
}
@Cacheable(value = "long-cache", sync = true)
public Optional<FinanceIndicator> findFinanceIndicator(Long stockId, Integer year) {
return financeIndicatorRepository.findOne(
QFinanceIndicator.financeIndicator.year.eq(year)
@@ -41,6 +43,7 @@ public class StockService extends SimpleServiceSupport<Stock> {
);
}
@Cacheable(value = "long-cache", sync = true)
public List<FinanceIndicator> findFinanceIndicatorRecent(Long stockId, int years) {
var current = LocalDate.now();
return financeIndicatorRepository.findAll(
@@ -50,6 +53,7 @@ public class StockService extends SimpleServiceSupport<Stock> {
);
}
@Cacheable(value = "long-cache", sync = true)
public List<Daily> findDailyRecent(Long stockId, int days) {
var current = LocalDate.now();
return dailyRepository.findAll(
@@ -59,6 +63,7 @@ public class StockService extends SimpleServiceSupport<Stock> {
);
}
@Cacheable(value = "long-cache", sync = true)
public Optional<Daily> findDailyLatest(Long stockId) {
return dailyRepository.findLatest(stockId);
}