Skip to main content

从 Redis 查询 KEYS 并执行高效的 MGET。帮助查询您的 Redis。

项目描述

Redis 批量获取

使用 KEYS 和 MGET 查询您的 Redis 以将键/值写入标准输出或文件。它支持格式:文本、json 和 csv。

安装

从 PIP 安装:

pip install redis-mass-get

命令行使用

该项目可以用作 CLI 工具:

usage: redis-mass-get [-h] [-q] [-f {text,csv,json}] [-d DESTINATION] [-jd] [-c CHUNCKS] [-och] url key

Queries Redis using KEYS and MGET. This will efficiently retreive all keys and values. They can be stored/visualized in different modes: - text (default): odd lines are keys, even lines values. - csv: comma-separated format. - json: JSON-array. Use -jd to decode the JSON value.

positional arguments:
  url                   Full Redis URL.
  key                   The key to query on.

optional arguments:
  -h, --help            show this help message and exit
  -q, --quiet           Don't show information about the progress.
  -f {text,csv,json}, --format {text,csv,json}
                        The format in which the keys of values should be.
  -d DESTINATION, --destination DESTINATION
                        Writes the output to a file.
  -jd, --json_decode    Enables JSON decode when writing to JSON.
  -c CHUNCKS, --chuncks CHUNCKS
                        How many keys should be queried at once? Default is 10,000.
  -och, --omit_csv_header
                        Don't render a CSV header.

别名rmgorredis_mass_get也可以在控制台中使用。

API

API 可以这样使用:

from redis_mass_get import RedisQuery

# pluralize will return the result or None
q = RedisQuery("redis://my.amazing.redis.url")

# query data 
data = q.query("prefix*")
# data is returned as:
# [(key1, value1), (key2, value2)]

# write data to file
# TXT:
q.query_and_write_csv(self, "prefix*", "my.file.path.txt")

# CSV:
q.query_and_write_csv(self, "*postfix", "my.file.path.csv")

# JSON
q.query_and_write_csv(self, "*contains*", "my.file.path.csv", parse_value_as_json=True)

您还可以编写自己的实现ProcessorBase并调用query_with_processor.

发展

如果您想为本地开发做出贡献,请咨询本地开发页面。关于这个包背后的推理的更多信息可以在这个博客中找到:从 Redis 读取多个键/值

项目详情


下载文件

下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。

源分布

redis-mass-get-0.0.11.tar.gz (6.7 kB 查看哈希)

已上传 source

内置分布

redis_mass_get-0.0.11-py3-none-any.whl (9.0 kB 查看哈希

已上传 py3