Redisson如何序列化长整型

huangapple go评论69阅读模式
英文:

how redisson serialize long

问题

I use redisson to store Long values:

RSet 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?

英文:

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&lt;Long&gt; set = client.getSet(&quot;myset&quot;,LongCodec.INSTANCE);
set.add(Long.valueOf(n));

huangapple
  • 本文由 发表于 2020年7月28日 09:46:29
  • 转载请务必保留本文链接:https://go.coder-hub.com/63125892.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定