您能否给出一个在 Python 中使用 Redis 的非常简单的示例 xread
和 xadd
(显示 xread 的返回值的类型和格式以及 xadd 的输入)?我已经阅读了很多文档,但没有一个是用 Python 编写的。
Redis 文档 给出了一个例子:
> XADD mystream * sensor-id 1234 temperature 19.8
1518951480106-0
但如果我在 python 中尝试:
sample = {b"hello":b"12"}
id = r.xadd("mystream", sample)
我收到此错误:
redis.exceptions.ResponseError: WRONGTYPE Operation against a key holding the wrong kind of value
原文由 AgnosticCucumber 发布,翻译遵循 CC BY-SA 4.0 许可协议
确保在运行之前进行刷新以确保不存在具有相同名称的列表/流。 :