I'm using Jedis as the java client to connect to Redis servers. I am also using protocol buffers to write the data in jedis or redis cache. But I'm not finding the way how to write or set the protobuf object to redis. Am I missing something or Jedis doesn't provide the way to store protobuf object as value?
This is a late answer...
You can serialize the Protobuf message into a binary string, and save it to Redis using the SET
command. However, whenever you need to get the Protobuf message, you have to get the binary string back, and deserialize it. Even if you only want to get a single field.
Another solution is that you can use the redis-protobuf module to save the Protobuf message into Redis. With this module, you can read or write the Protobuf message. If you only need a single field, you don't need to get the whole message back, redis-protobuf
will only return that field.
Disclaimer: I'm the author of redis-protobuf
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With