Fixed - RLocalCachedMap.containsKey() does not work properly if storeCacheMiss = true. #5411

pull/5427/head
Nikita Koksharov 1 year ago
parent d85a8f60c2
commit cc4573b4a8

@ -233,13 +233,27 @@ public class RedissonLocalCachedMap<K, V> extends RedissonMap<K, V> implements R
return new CompletableFutureWrapper<>(f); return new CompletableFutureWrapper<>(f);
} }
CompletableFuture<V> promise = new CompletableFuture<>(); String name = getRawName(key);
promise.thenAccept(value -> { RFuture<Boolean> future = containsKeyOperationAsync(name, key);
if (storeCacheMiss || value != null) { CompletionStage<Boolean> result = future.thenCompose(res -> {
cachePut(cacheKey, key, value); if (hasNoLoader()) {
if (!res && storeCacheMiss) {
cachePut(cacheKey, key, null);
}
return CompletableFuture.completedFuture(res);
}
if (!res) {
CompletableFuture<V> f = loadValue((K) key, false);
return f.thenApply(value -> {
if (storeCacheMiss || value != null) {
cachePut(cacheKey, key, value);
}
return value != null;
});
} }
return CompletableFuture.completedFuture(res);
}); });
return containsKeyAsync(key, promise); return new CompletableFutureWrapper<>(result);
} }
return new CompletableFutureWrapper<>(cacheValue.getValue() != null); return new CompletableFutureWrapper<>(cacheValue.getValue() != null);

Loading…
Cancel
Save