redis-protobuf: a Redis Module reading and writing Protobuf messages

19 views
Skip to first unread message

new sewe

unread,
Jul 9, 2019, 11:41:54 PM7/9/19
to Protocol Buffers
Hi all,

I wrote a Redis Module: redis-protobuf, which can read and write Protobuf messages.

This module uses Protobuf Reflection to operate Protobuf messages, so you only need to provide .proto files, then you can read and write these pre-defined Protobuf messages.

Please see the doc for more info.

You can try the following examples with a docker image:


127.0.0.1:6379> MODULE LIST
1) 1) "name"
   2) "PB"
   3) "ver"
   4) (integer) 0
127.0.0.1:6379> PB.SCHEMA Msg
"message Msg {\n  int32 i = 1;\n  SubMsg sub = 2;\n  repeated int32 arr = 3;\n}\n"
127.0.0.1:6379> PB.SET key Msg '{"i" : 1, "sub" : {"s" : "string", "i" : 2}, "arr" : [1, 2, 3]}'
(integer) 1
127.0.0.1:6379> PB.GET key --FORMAT JSON Msg
"{\"i\":1,\"sub\":{\"s\":\"string\",\"i\":2},\"arr\":[1,2,3]}"
127.0.0.1:6379> PB.SET key Msg.i 10
(integer) 1
127.0.0.1:6379> PB.SET key Msg.sub.s redis-protobuf
(integer) 1
127.0.0.1:6379> PB.SET key Msg.arr[0] 2
(integer) 1
127.0.0.1:6379> PB.GET key Msg.i
(integer) 10
127.0.0.1:6379> PB.GET key Msg.sub.s
"redis-protobuf"
127.0.0.1:6379> PB.GET key Msg.arr[0]
(integer) 2
127.0.0.1:6379> PB.GET key --FORMAT JSON Msg.sub
"{\"s\":\"redis-protobuf\",\"i\":2}"
127.0.0.1:6379> PB.DEL key Msg
(integer) 1

If you have any problem or suggestion on this module, free feel to let me know.

Regards
Reply all
Reply to author
Forward
0 new messages