Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to store protobuffer object in redis cache?

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?

like image 316
Mick Avatar asked Oct 16 '15 12:10

Mick


1 Answers

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.

like image 174
for_stack Avatar answered Oct 19 '22 17:10

for_stack