Skip to content

Commit 54197a0

Browse files
committed
name changing to putIfAbsentAtomically
1 parent c026da6 commit 54197a0

File tree

6 files changed

+7
-7
lines changed

6 files changed

+7
-7
lines changed

src/main/java/org/dataloader/CacheMap.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ static <K, V> CacheMap<K, V> simpleMap() {
9191
*
9292
* @return the cache map for fluent coding
9393
*/
94-
CompletableFuture<V> setIfAbsent(K key, CompletableFuture<V> value);
94+
CompletableFuture<V> putIfAbsentAtomically(K key, CompletableFuture<V> value);
9595

9696
/**
9797
* Deletes the entry with the specified key from the cache map, if it exists.

src/main/java/org/dataloader/DataLoader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ public DataLoader<K, V> prime(K key, Exception error) {
448448
*/
449449
public DataLoader<K, V> prime(K key, CompletableFuture<V> value) {
450450
Object cacheKey = getCacheKey(key);
451-
futureCache.setIfAbsent(cacheKey, value);
451+
futureCache.putIfAbsentAtomically(cacheKey, value);
452452
return this;
453453
}
454454

src/main/java/org/dataloader/DataLoaderHelper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ CompletableFuture<V> load(K key, Object loadContext) {
168168
if (batchingEnabled) {
169169
loadCallFuture = new CompletableFuture<>();
170170
if (futureCachingEnabled) {
171-
CompletableFuture<V> cachedFuture = futureCache.setIfAbsent(cacheKey, loadCallFuture);
171+
CompletableFuture<V> cachedFuture = futureCache.putIfAbsentAtomically(cacheKey, loadCallFuture);
172172
if (cachedFuture != null) {
173173
// another thread was faster and created a matching CF ... hence this is really a cachehit and we are done
174174
stats.incrementCacheHitCount(new IncrementCacheHitCountStatisticsContext<>(key, loadContext));
@@ -183,7 +183,7 @@ CompletableFuture<V> load(K key, Object loadContext) {
183183
// immediate execution of batch function
184184
loadCallFuture = invokeLoaderImmediately(key, loadContext, true);
185185
if (futureCachingEnabled) {
186-
CompletableFuture<V> cachedFuture = futureCache.setIfAbsent(cacheKey, loadCallFuture);
186+
CompletableFuture<V> cachedFuture = futureCache.putIfAbsentAtomically(cacheKey, loadCallFuture);
187187
if (cachedFuture != null) {
188188
// another thread was faster and the loader was invoked twice with the same key
189189
// we are disregarding the resul of our dispatch call and use the already cached value

src/main/java/org/dataloader/impl/DefaultCacheMap.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public Collection<CompletableFuture<V>> getAll() {
7272
* {@inheritDoc}
7373
*/
7474
@Override
75-
public CompletableFuture<V> setIfAbsent(K key, CompletableFuture<V> value) {
75+
public CompletableFuture<V> putIfAbsentAtomically(K key, CompletableFuture<V> value) {
7676
return cache.putIfAbsent(key, value);
7777
}
7878

src/test/java/ReadmeExamples.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ public Collection<CompletableFuture<Object>> getAll() {
265265
}
266266

267267
@Override
268-
public CompletableFuture<Object> setIfAbsent(Object key, CompletableFuture value) {
268+
public CompletableFuture<Object> putIfAbsentAtomically(Object key, CompletableFuture value) {
269269
return null;
270270
}
271271

src/test/java/org/dataloader/fixtures/CustomCacheMap.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public Collection<CompletableFuture<Object>> getAll() {
3030
}
3131

3232
@Override
33-
public CompletableFuture<Object> setIfAbsent(String key, CompletableFuture<Object> value) {
33+
public CompletableFuture<Object> putIfAbsentAtomically(String key, CompletableFuture<Object> value) {
3434
return stash.putIfAbsent(key, value);
3535
}
3636

0 commit comments

Comments
 (0)