1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| /core/internal/cache/RetrieveRecord.java <T> Record<T> retrieveRecord(String providerKey, String dynamicKey, String dynamicKeyGroup, boolean useExpiredDataIfLoaderNotAvailable, Long lifeTime, boolean isEncrypted) { String composedKey = composeKey(providerKey, dynamicKey, dynamicKeyGroup);
Record<T> record = memory.getIfPresent(composedKey);
if (record != null) { record.setSource(Source.MEMORY); } else { try { record = persistence.retrieveRecord(composedKey, isEncrypted, encryptKey); record.setSource(Source.PERSISTENCE); memory.put(composedKey, record); } catch (Exception ignore) { return null; } }
record.setLifeTime(lifeTime);
// 删除缓存过期的逻辑 // if (hasRecordExpired.hasRecordExpired(record)) { // if (!dynamicKeyGroup.isEmpty()) { // evictRecord.evictRecordMatchingDynamicKeyGroup(providerKey, dynamicKey, // dynamicKeyGroup); // } else if (!dynamicKey.isEmpty()) { // evictRecord.evictRecordsMatchingDynamicKey(providerKey, dynamicKey); // } else { // evictRecord.evictRecordsMatchingProviderKey(providerKey); // } // // return useExpiredDataIfLoaderNotAvailable ? record : null; // } return record; }
|