Исходные комментарии являются хорошим справочным материалом для просмотра ожидаемых типов. str
будет делать большую часть времени, но некоторые команды ожидают некоторых других типов в некоторых аргументах.
Например, см. XCLAIM
в 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
в качестве строки. Вот пример на тестах .
r.set(key, b'\xff\xf0\x00')
Вы также можете использовать bytearray
на клавише.