Skip to content

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

@Neeraj0019

Description

@Neeraj0019

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions