英文:
how redisson serialize long
问题
I use redisson to store Long values:
RSet
set.add(Long.valueOf(n));
But I get an unreadable value:
> SMEMBERS myset
1) "\t\x84\xe2\x02"
How can I retrieve this value without redisson?
英文:
I use redisson to store Long values:
RSet<Long> set = client.getSet("myset");
set.add(Long.valueOf(n));
But I get an unreadable value:
> SMEMBERS myset
1) "\t\x84\xe2\x02"
How can I retrieve this value without redisson?
答案1
得分: 2
自Redisson 3.13.0版本开始,默认的编解码器是MarshallingCodec,在此之前是FSTCodec。这两者都将数据序列化为不可读的二进制格式。
如果要序列化长整型和整型值,Redisson提供了LongCodec。相应的代码如下:
RSet<Long> set = client.getSet("myset", LongCodec.INSTANCE);
set.add(Long.valueOf(n));
英文:
The default codec for Redisson from version 3.13.0 is MarshallingCodec and before that it was FSTCodec. Both of these serialize to binary formats which are not human readable.
To serialize long and integer values Redisson offers LongCodec. The corresponding code will look like this:
RSet<Long> set = client.getSet("myset",LongCodec.INSTANCE);
set.add(Long.valueOf(n));
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论