diff --git a/client/src/com/aerospike/client/Value.java b/client/src/com/aerospike/client/Value.java index 0dc598846..3325d3022 100644 --- a/client/src/com/aerospike/client/Value.java +++ b/client/src/com/aerospike/client/Value.java @@ -1356,6 +1356,8 @@ public int hashCode() { * HyperLogLog value. */ public static final class HLLValue extends Value { + private volatile LuaBytes cachedLuaValue; + private final byte[] bytes; public HLLValue(byte[] bytes) { @@ -1399,7 +1401,16 @@ public byte[] getBytes() { @Override public LuaValue getLuaValue(LuaInstance instance) { - return new LuaBytes(instance, bytes); + LuaBytes result = cachedLuaValue; + if (result == null) { + synchronized (this) { + result = cachedLuaValue; + if (result == null) { + cachedLuaValue = result = new LuaBytes(instance, bytes); + } + } + } + return result; } @Override