我有以下代码,我想在“instagramSearchResultsCache”中获取数据。例如,如何使用 Spring Cache 来打印它?
@Cacheable(value = "instagramSearchResultsCache", key = "#tagName")
public ArrayList<SingleInstagramDTO> getInstagramData(String tagName) {
JSONObject jsonObject = sendGETRestTemplate(tagName);
if (jsonObject == null) {
return null;
}
JSONArray arr = jsonObject.optJSONArray("data");
ArrayList<SingleInstagramDTO> instagramRestObjectsList = new ArrayList<>();
for (int i = 0; i < arr.length(); i++) {
JSONObject jsonElement = arr.optJSONObject(i);
InstagramFormatter formatter = new InstagramFormatter(jsonElement);
JSONObject instagramJSONObject = formatter.getResultInstagramObject();
instagramRestObjectsList.add(new SingleInstagramDTO(instagramJSONObject));
}
return instagramRestObjectsList;
}