optimization: don't take lock for computeIfAbsent if only get is needed

Signed-off-by: Shreyas Gupta <shreyas.gupta1@sprinklr.com>
pull/6089/head
Shreyas Gupta 6 months ago
parent 5ec516a0d1
commit e5fe0d5037

@ -325,10 +325,15 @@ public class RedissonMap<K, V> extends RedissonExpirable implements RMap<K, V> {
checkKey(key);
Objects.requireNonNull(mappingFunction);
V value = get(key);
if (value != null) {
return value;
}
RLock lock = getLock(key);
lock.lock();
try {
V value = get(key);
value = get(key);
if (value == null) {
V newValue = mappingFunction.apply(key);
if (newValue != null) {

Loading…
Cancel
Save