Skip to content

Commit

Permalink
fixed redis longvalue codec value decoder
Browse files Browse the repository at this point in the history
  • Loading branch information
ag060 committed Jan 20, 2025
1 parent 4524fed commit 58de2db
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ public String decodeKey(ByteBuffer bytes) {

@Override
public Long decodeValue(ByteBuffer bytes) {
if (!bytes.hasRemaining()) return null;
return bytes.getLong();
String valueAsString = StandardCharsets.UTF_8.decode(bytes).toString();
return Long.parseLong(valueAsString);
}

@Override
Expand All @@ -24,9 +24,7 @@ public ByteBuffer encodeKey(String key) {

@Override
public ByteBuffer encodeValue(Long value) {
ByteBuffer buffer = ByteBuffer.allocate(Long.BYTES);
buffer.putLong(value);
buffer.flip();
return buffer;
String valueAsString = value.toString();
return StandardCharsets.UTF_8.encode(valueAsString);
}
}

0 comments on commit 58de2db

Please sign in to comment.