Skip to content

Make kvrocks dump rdb file which redis can load. #1001

@ColinChamber

Description

@ColinChamber

Search before asking

  • I had searched in the issues and found no similar issues.

Motivation

Making Kvrocks write RDB is more straightforward than making it parse RDB.
Because Redis is backward compatible, which can load the original RDB file.
We can easily utilize the primitive RDB object types, which follow the simple
encoding pattern:
or ( consists of <key(value)>)
RDB_TYPE_STRING, RDB_TYPE_LIST, RDB_TYPE_SET, RDB_TYPE_ZSET, RDB_TYPE_HASH,
these five types follow this pattern. We ignore the RDB_TYPE_HASH_ZIPMAP,
RDB_TYPE_LIST_ZIPLIST, RDB_TYPE_SET_INTSET, and other complicated types
only implement the five simple type.

There is a mapping relationship between Redis object type and RDB object type.
But you don't have to worry about Redis using ineffective object types after loading RDB.
Redis will convert it to an efficient type automatically.
E.g
kvrocks> hmset foo foo1 bar1 foo2 bar2
kvrocks> save (use RDB_TYPE_HASH rather than RDB_TYPE_HASH_ZIPLIST)
-------- Redis loads the RDB that kvrocks dumped --------
redis> OBJECT ENCODING foo
"ziplist"

There are more detailed references to RDB.
https://github.com/sripathikrishnan/redis-rdb-tools/wiki/Redis-RDB-Dump-File-Format
https://github.com/sripathikrishnan/redis-rdb-tools/blob/master/docs/RDB_Version_History.textile
https://rdb.fnordig.de/file_format.html

Solution

#958

Are you willing to submit a PR?

  • I'm willing to submit a PR!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions