为什么密钥没有出现在缓存中?

时间:2019-07-02 07:27:41

标签: spring caching key-value

我正在查询数据库并将结果存储在缓存中。关键是列的组合。当我尝试通过HTTP请求进行查询时,某些键存在而其他键则丢失。

while (res.next()) {
                CardMetricDetailRecord cardMetricDetailRecord = new CardMetricDetailRecord(
                        res.getString("JSON_FILE_NAME"),
                        res.getString("name"),
                        res.getString("description"),
                        ......
                );

                cardMetricDetailRecordList.add(cardMetricDetailRecord);
                String vizId = res.getString("child_id");
                String key = vizId + "+" + cardMetricDetailRecord.getLob() + "+" + cardMetricDetailRecord.getRegion() + "+" + cardMetricDetailRecord.getMetricId();
                if (cacheManager.getCache("Temp").get(key) != null) {

                    List<CardMetricDetailRecord> tmp1 = (List<CardMetricDetailRecord>) cacheManager.getCache("Temp").get(key).get();

                    cardMetricDetailRecordList.addAll(tmp1);
                    }

                cacheManager.getCache("Temp").put(key, cardMetricDetailRecordList);

                cardMetricDetailRecordList = new ArrayList<CardMetricDetailRecord>();


            }

预期获得JSON结果,但一无所获,

enter image description here

0 个答案:

没有答案