|
|
@@ -10,6 +10,7 @@ import org.springframework.dao.DataAccessException;
|
|
|
import org.springframework.data.redis.connection.RedisConnection;
|
|
|
import org.springframework.data.redis.core.RedisCallback;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
+import org.springframework.http.client.SimpleClientHttpRequestFactory;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
@@ -33,13 +34,16 @@ public class NewsServiceImpl implements NewsService {
|
|
|
/**
|
|
|
* 缓存刷新时间
|
|
|
*/
|
|
|
- @Value("#{sys.newsRedisRefresh ?: 300}")
|
|
|
+ @Value("#{sys.newsRedisRefresh ?: 1800}")
|
|
|
private long newsRedisRefresh;
|
|
|
|
|
|
@Autowired
|
|
|
public NewsServiceImpl(MicroServicesConf conf, RestTemplate restTemplate, RedisTemplate redisTemplate) {
|
|
|
this.conf = conf;
|
|
|
- this.restTemplate = restTemplate;
|
|
|
+ SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
|
|
|
+ requestFactory.setConnectTimeout(5000);
|
|
|
+ requestFactory.setReadTimeout(5000);
|
|
|
+ this.restTemplate = new RestTemplate(requestFactory);
|
|
|
this.redisTemplate = redisTemplate;
|
|
|
}
|
|
|
|