|
@@ -8,6 +8,7 @@ import com.danielbohry.stocks.repository.StockInfoRepository;
|
|
|
import com.danielbohry.stocks.repository.StockRepository;
|
|
import com.danielbohry.stocks.repository.StockRepository;
|
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.AllArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
+import org.springframework.cache.annotation.Cacheable;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
@@ -25,6 +26,7 @@ public class StockInfoService {
|
|
|
private StockRepository stockRepository;
|
|
private StockRepository stockRepository;
|
|
|
private StockInfoRepository infoRepository;
|
|
private StockInfoRepository infoRepository;
|
|
|
|
|
|
|
|
|
|
+ @Cacheable(value = "stockInfo", key = "#code")
|
|
|
public StockInfo get(String code) {
|
|
public StockInfo get(String code) {
|
|
|
return infoRepository.findById(code)
|
|
return infoRepository.findById(code)
|
|
|
.orElseThrow(() -> new NotFoundException("No stock found with id: " + code));
|
|
.orElseThrow(() -> new NotFoundException("No stock found with id: " + code));
|