Skip to content

joshuawscott/rdb_parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RdbParser

Parses a redis backup (.rdb) file.

Current features:

Parses strings, sets, and lists, with or without expirations.

Other formats will be supported eventaully (Pull requests welcome :))

Installation

If available in Hex, the package can be installed by adding rdb_parser to your list of dependencies in mix.exs:

def deps do
  [
    {:rdb_parser, "~> 0.1.0"}
  ]
end

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at hexdocs.pm/rdb_parser

Usage

Store the contents of a dump file in a map called database:

database =
  "dump.rdb"
  |> RdbParser.stream_entries()
  |> Enum.reduce(%{}, fn
    {:entry, {key, value, metadata}}, accum ->
      Map.put(accum, key, {value, metadata})

    _, accum ->
      # Ignore the non-data entries
      accum
  end)

Testing

The tests use Redix to connect to a running Redis server, insert keys, and save the database.

To work, you must start redis-server with the default options from the root of the repo:

redis-server

Then you can run the tests with:

mix test

About

Redis .rdb backup file parsing

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages