redis aof文件解析成命令

waoffle

A Redis AOF file parser. This module parses an AOF structure like this:

AOF文件解析器。这个模块解析一个AOF结构是这样的:

 
  1. *3

  2. $9

  3. PEXPIREAT

  4. $10

  5. myRedisKey

  6. $13

  7. 1719298712484

  8. *3

  9. $3

  10. SET

  11. $9

  12. myJSONKey

  13. $24

  14. {"someKey": "someValue"}

... into raw Redis commands, like this:

生成命令行如下:

 
  1. PEXPIREAT myRedisKey 1719298712484

  2. SET myJSONKey {"someKey": "someValue"}

The opposite can also be achieved by using the reverse binary (rwaoffle) also provided in this module.

相反的也可以通过使用逆向二进制(rwaoffle)也提供了在这个模块。

Installation/Usage

You can install this module via npm:

$ npm install -g waoffle

This installs a global binary waoffle to which you can use to pipe your syrup data to:

$ cat appendonly.aof | waoffle  # Pipe from other UNIX commands
$ waoffle < appendonly.aof      # or, pipe directly from stdin
$ waoffle appendonly.aof        # or, just specify the filename

Each of the three cases above are equivalent. The generated output will be streamed to stdout, to which you can dump into a file using redirection:

上面三种情况下是等价的。生成的输出流发送到stdout,你可以转储到一个文件中使用重定向:

$ waoffle < appendonly.aof > generated_commands.txt

The reverse process—going from sets of operations to AOF format—can be achieved in the same manner by substituting calls towaoffle for rwaoffle.

Importing data into Redis

This is useful for importing data directly into a running Redis instance. Simply use the rwaoffle command if you are starting with a file full of operations. Even though Redis can already read its own AOF file format, this set of tools is even more powerful for filtering your AOF files:

这是用于将数据直接导入到运行的复述实例。仅仅使用rwaoffle命令,如果你从一个文件的操作。虽然复述,已经可以读自己的AOF文件格式,这组工具是更强大的过滤AOF文件:

$ waoffle < appendonly.aof | grep SET | rwaoffle    # Only grab `SET` operations

Use this in combination with redis-cli --pipe for maximum win:

$ cat appendonly.aof | redis-cli --pipe             # Standard Redis import
$ cat commands.txt | rwaoffle | redis-cli --pipe    # Importing a list of commands
$ cat appendonly.aof | waoffle | grep SET \
      | rwaoffle | redis-cli --pipe                 # Import only `SET` operations
 
参考:https://github.com/nvite/waoffle

猜你喜欢

转载自blog.csdn.net/zzy7075/article/details/107379224