Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions 3 src/main/java/org/dataloader/CacheMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ static <K, V> CacheMap<K, V> simpleMap() {
/**
* Gets the specified key from the cache map.
* <p>
* May throw an exception if the key does not exist, depending on the cache map implementation that is used,
* so be sure to check {@link CacheMap#containsKey(Object)} first.
* May throw an exception if the key does not exist, depending on the cache map implementation that is used.
*
* @param key the key to retrieve
*
Expand Down
22 changes: 15 additions & 7 deletions 22 src/main/java/org/dataloader/DataLoaderHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,13 @@ Optional<CompletableFuture<V>> getIfPresent(K key) {
boolean cachingEnabled = loaderOptions.cachingEnabled();
if (cachingEnabled) {
Object cacheKey = getCacheKey(nonNull(key));
if (futureCache.containsKey(cacheKey)) {
stats.incrementCacheHitCount(new IncrementCacheHitCountStatisticsContext<>(key));
return Optional.of(futureCache.get(cacheKey));
try {
CompletableFuture<V> cacheValue = futureCache.get(cacheKey);
if (cacheValue != null) {
stats.incrementCacheHitCount(new IncrementCacheHitCountStatisticsContext<>(key));
return Optional.of(cacheValue);
}
} catch (Exception ignored) {
}
}
}
Expand Down Expand Up @@ -307,10 +311,14 @@ private void possiblyClearCacheEntriesOnExceptions(List<K> keys) {
private CompletableFuture<V> loadFromCache(K key, Object loadContext, boolean batchingEnabled) {
final Object cacheKey = loadContext == null ? getCacheKey(key) : getCacheKeyWithContext(key, loadContext);

if (futureCache.containsKey(cacheKey)) {
// We already have a promise for this key, no need to check value cache or queue up load
stats.incrementCacheHitCount(new IncrementCacheHitCountStatisticsContext<>(key, loadContext));
return futureCache.get(cacheKey);
try {
CompletableFuture<V> cacheValue = futureCache.get(cacheKey);
if (cacheValue != null) {
// We already have a promise for this key, no need to check value cache or queue up load
stats.incrementCacheHitCount(new IncrementCacheHitCountStatisticsContext<>(key, loadContext));
return cacheValue;
}
} catch (Exception ignored) {
}

CompletableFuture<V> loadCallFuture = queueOrInvokeLoader(key, loadContext, batchingEnabled, true);
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.