0

com / twitter / finagle / memcached / Client extends BaseClient[ChannelBuffer]

so the set is defined as

set(key: String, flags: Int, expiry: Time, value: ChannelBuffer): Future[Unit]

My question is how can I convert my java Object to a netty ChannelBuffer or I have some other way to set object other than String?

Thanks

jordan
  • 711
  • 1
  • 8
  • 17

2 Answers2

1

Finally, I used thrift to do the serialization. It's just my case, because I have heavily used thrift.

The disadvantage of thrift serialization: you had to define the struct of the object in the IDL.

The advantage is: simple

TSerializer serializer = new TSerializer();
byte[] bytes = serializer.serialize(obj);
ChannelBuffer buffer = ChannelBufferUtils.bytesToChannelBuffer(bytes);
jordan
  • 711
  • 1
  • 8
  • 17
0

It's up to you! You can use whatever serialization library you want, there is plenty of alternatives. memcached only consider it as a array of bytes.

Steve Gury
  • 15,158
  • 6
  • 38
  • 42