Skip to content

Commit

Permalink
Add missing LongCodec to RedisCommandBuilder #2481
Browse files Browse the repository at this point in the history
  • Loading branch information
mp911de committed Aug 16, 2023
1 parent da70168 commit 1be0d1a
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/main/java/io/lettuce/core/RedisCommandBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -4201,4 +4201,33 @@ private static void notEmptyRanges(Range<?>[] ranges) {
LettuceAssert.notEmpty(ranges, "Ranges " + MUST_NOT_BE_NULL);
}

enum LongCodec implements RedisCodec<Long, Long> {

INSTANCE;

@Override
public Long decodeKey(ByteBuffer bytes) {

String s = StringCodec.ASCII.decodeKey(bytes);

return s == null ? null : Long.valueOf(s);
}

@Override
public Long decodeValue(ByteBuffer bytes) {
return decodeKey(bytes);
}

@Override
public ByteBuffer encodeKey(Long key) {
return StringCodec.ASCII.encodeKey(key == null ? null : key.toString());
}

@Override
public ByteBuffer encodeValue(Long value) {
return encodeKey(value);
}

}

}

0 comments on commit 1be0d1a

Please sign in to comment.