Skip to content

Implement RDB File Reading on Startup #14

@proXDhiya

Description

@proXDhiya

Implement functionality to read an RDB (Redis Data Persistence) file at the start of the program. The file will be provided via --dir and --dbfilename options. If the specified RDB file does not exist, the program should treat the database as empty.

Requirements:

  • On program start, check if the RDB file specified by --dir and --dbfilename exists:
    • If the file exists, read and load the database from it.
    • If the file does not exist, initialize the database as empty.
  • Implement support for reading numbers stored in the RDB file using both little-endian and big-endian formats, as per the RDB specification.
  • Integrate the reading functionality with the SAVE command to ensure that a valid RDB file is generated and can be read back correctly.

Acceptance Criteria:

  • The program correctly reads an existing RDB file at startup, loading the database with its contents.
  • If the RDB file does not exist, the program initializes with an empty database.
  • The program can correctly interpret numbers stored in little-endian and big-endian formats within the RDB file.
  • The RDB file generated by the SAVE command is valid and can be successfully read on subsequent startups.

Additional Notes:

  • Refer to the MDN article on endianness to understand how to handle little-endian and big-endian formats.
  • Ensure the implementation is robust, handling edge cases such as corrupted or partially written RDB files.

Metadata

Metadata

Assignees

Labels

CommandNew commandRDBRedis DatabaseWorkerWorker updateenhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions