p / redis-dump-load

Dump redis databases, load data into redis - in Python
BSD 2-Clause "Simplified" License
175 stars 76 forks source link

What is the encoding format used for keys written in binary-safe mode in Redis? #66

Open Neeraj0019 opened 1 year ago

Neeraj0019 commented 1 year ago

We have some redis Hash keys which are storing values as c++ structures and for that we have used binary safe mode. Example:

redisReply* reply = (redisReply*)redisCommand(ctxt, "HMSET %b %b %b", KEY.c_str(), strlen(KEY.c_str()), &val,
                                            sizeof(KEY), &temp_element, sizeof(temp_element));

keys looks like this in redis DB:

1) "\x14\x10" 2) "KEY_dc8d8afe8e2a_301_0.4116_ECpriReceptionMonitor\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"

Where KEY is integer value and temp_element is a structure.

But when we try to take dump using redisdl module as show below:

db_dump=redisdl.dumps(db=db_instance,pretty=True)

it gives below error:

'utf-8' codec can't decode byte 0x90 in position 1: invalid start byte

we tried with encoding='iso-8859-1' seems to work but how to check if this is the correct encoding format?

Br, Neeraj