gpt4 book ai didi

python - 我应该使用什么数据类型作为 redis-py 函数的参数?

转载 作者:太空宇宙 更新时间:2023-11-03 19:48:29 24 4
gpt4 key购买 nike

例如,当我使用xack时,我是否需要将每个参数转换为字节,还是由客户端自动完成?

xack(name, groupname, *ids)

似乎使用 strbytes id 都可以,但我在文档中找不到对此的解释。相关源代码的链接将不胜感激。

最佳答案

源代码注释是查看预期类型的​​一个很好的引用。 str 大多数情况下都可以,但有些命令需要某些参数中的其他类型。

例如,请参阅 XCLAIM in client.py :

def xclaim(self, name, groupname, consumername, min_idle_time, message_ids,
idle=None, time=None, retrycount=None, force=False,
justid=False):
"""
Changes the ownership of a pending message.
name: name of the stream.
groupname: name of the consumer group.
consumername: name of a consumer that claims the message.
min_idle_time: filter messages that were idle less than this amount of
milliseconds
message_ids: non-empty list or tuple of message IDs to claim
idle: optional. Set the idle time (last time it was delivered) of the
message in ms
time: optional integer. This is the same as idle but instead of a
relative amount of milliseconds, it sets the idle time to a specific
Unix time (in milliseconds).
retrycount: optional integer. set the retry counter to the specified
value. This counter is incremented every time a message is delivered
again.
force: optional boolean, false by default. Creates the pending message
entry in the PEL even if certain specified IDs are not already in the
PEL assigned to a different client.
justid: optional boolean, false by default. Return just an array of IDs
of messages successfully claimed, without returning the actual message

您将在该文件中找到其他命令。

Redis 字符串是二进制安全的。您可以使用bytearray作为字符串。这里是example on the tests .

r.set(key, b'\xff\xf0\x00')

您也可以在键上使用bytearray

关于python - 我应该使用什么数据类型作为 redis-py 函数的参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59986848/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com