Search code examples
redismsgpackredis-cli

how to view decoded messagepack data in redis-cli


i have data stored in redis in messagepack. How to view the data decoded in redis-cli.

I don't see any commands related to it.


Solution

  • redis-cli has no pretty-print functionality (yet). However, as @Ryan Vincent had suggested, you can use a Redis Lua script for that purpose. Assuming that your MessagePack-ed data is stored in the String key called foo, this would do your bidding:

    EVAL "return cmsgpack.unpack(redis.call('GET', KEYS[1]))" 1 foo
    

    EDIT: the above assumes that the data is serialized as arrays. Returning an object will not work as Redis' protocol doesn't support that.