Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/joshuawscott/rdb_parser
Redis .rdb backup file parsing
https://github.com/joshuawscott/rdb_parser
elixir rdb redis
Last synced: about 2 months ago
JSON representation
Redis .rdb backup file parsing
- Host: GitHub
- URL: https://github.com/joshuawscott/rdb_parser
- Owner: joshuawscott
- License: mit
- Created: 2018-02-21T21:38:53.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-05-07T13:34:43.000Z (over 6 years ago)
- Last Synced: 2024-09-15T17:56:11.965Z (4 months ago)
- Topics: elixir, rdb, redis
- Language: Elixir
- Homepage:
- Size: 47.9 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# 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](https://hex.pm/docs/publish), the package can be installed
by adding `rdb_parser` to your list of dependencies in `mix.exs`:```elixir
def deps do
[
{:rdb_parser, "~> 0.1.0"}
]
end
```Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc)
and published on [HexDocs](https://hexdocs.pm). Once published, the docs can
be found at [hexdocs.pm/rdb_parser](https://hexdocs.pm/rdb_parser)## Usage
Store the contents of a dump file in a map called `database`:
```elixir
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
```