从 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-py3-none-any.whl 的哈希值
| 算法 | 哈希摘要 | |
|---|---|---|
| SHA256 | a9344691dd3ec8d8c7e27c7f710f14f9ee8270e1184685efd5ee66efd16f62ce |
|
| MD5 | 19754758e68121b34d09b4b5d9535f6a |
|
| 布莱克2-256 | d603d7c59a687cb5bb9391fe0c2ba9cf999b8fed6799fdd2de96146a94648f0c |