redis 6.0.0b2__py3-none-any.whl → 6.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- redis/__init__.py +9 -1
- redis/_parsers/resp3.py +2 -2
- redis/asyncio/client.py +75 -68
- redis/asyncio/cluster.py +67 -46
- redis/asyncio/connection.py +7 -5
- redis/asyncio/retry.py +12 -0
- redis/backoff.py +54 -0
- redis/client.py +95 -87
- redis/cluster.py +1084 -360
- redis/commands/core.py +104 -104
- redis/commands/helpers.py +19 -6
- redis/commands/json/__init__.py +1 -1
- redis/commands/json/commands.py +8 -8
- redis/commands/redismodules.py +20 -10
- redis/commands/search/commands.py +2 -2
- redis/commands/timeseries/__init__.py +1 -1
- redis/connection.py +7 -5
- redis/exceptions.py +18 -0
- redis/retry.py +25 -0
- {redis-6.0.0b2.dist-info → redis-6.1.0.dist-info}/METADATA +14 -8
- {redis-6.0.0b2.dist-info → redis-6.1.0.dist-info}/RECORD +23 -23
- {redis-6.0.0b2.dist-info → redis-6.1.0.dist-info}/WHEEL +0 -0
- {redis-6.0.0b2.dist-info → redis-6.1.0.dist-info}/licenses/LICENSE +0 -0
redis/commands/core.py
CHANGED
|
@@ -63,7 +63,7 @@ class ACLCommands(CommandsProtocol):
|
|
|
63
63
|
see: https://redis.io/topics/acl
|
|
64
64
|
"""
|
|
65
65
|
|
|
66
|
-
def acl_cat(self, category:
|
|
66
|
+
def acl_cat(self, category: Optional[str] = None, **kwargs) -> ResponseT:
|
|
67
67
|
"""
|
|
68
68
|
Returns a list of categories or commands within a category.
|
|
69
69
|
|
|
@@ -92,7 +92,7 @@ class ACLCommands(CommandsProtocol):
|
|
|
92
92
|
"""
|
|
93
93
|
return self.execute_command("ACL DELUSER", *username, **kwargs)
|
|
94
94
|
|
|
95
|
-
def acl_genpass(self, bits:
|
|
95
|
+
def acl_genpass(self, bits: Optional[int] = None, **kwargs) -> ResponseT:
|
|
96
96
|
"""Generate a random password value.
|
|
97
97
|
If ``bits`` is supplied then use this number of bits, rounded to
|
|
98
98
|
the next multiple of 4.
|
|
@@ -137,7 +137,7 @@ class ACLCommands(CommandsProtocol):
|
|
|
137
137
|
"""
|
|
138
138
|
return self.execute_command("ACL LIST", **kwargs)
|
|
139
139
|
|
|
140
|
-
def acl_log(self, count:
|
|
140
|
+
def acl_log(self, count: Optional[int] = None, **kwargs) -> ResponseT:
|
|
141
141
|
"""
|
|
142
142
|
Get ACL logs as a list.
|
|
143
143
|
:param int count: Get logs[0:count].
|
|
@@ -190,8 +190,8 @@ class ACLCommands(CommandsProtocol):
|
|
|
190
190
|
username: str,
|
|
191
191
|
enabled: bool = False,
|
|
192
192
|
nopass: bool = False,
|
|
193
|
-
passwords: Union[str, Iterable[str]
|
|
194
|
-
hashed_passwords: Union[str, Iterable[str]
|
|
193
|
+
passwords: Optional[Union[str, Iterable[str]]] = None,
|
|
194
|
+
hashed_passwords: Optional[Union[str, Iterable[str]]] = None,
|
|
195
195
|
categories: Optional[Iterable[str]] = None,
|
|
196
196
|
commands: Optional[Iterable[str]] = None,
|
|
197
197
|
keys: Optional[Iterable[KeyT]] = None,
|
|
@@ -450,13 +450,13 @@ class ManagementCommands(CommandsProtocol):
|
|
|
450
450
|
|
|
451
451
|
def client_kill_filter(
|
|
452
452
|
self,
|
|
453
|
-
_id:
|
|
454
|
-
_type:
|
|
455
|
-
addr:
|
|
456
|
-
skipme:
|
|
457
|
-
laddr:
|
|
458
|
-
user: str = None,
|
|
459
|
-
maxage:
|
|
453
|
+
_id: Optional[str] = None,
|
|
454
|
+
_type: Optional[str] = None,
|
|
455
|
+
addr: Optional[str] = None,
|
|
456
|
+
skipme: Optional[bool] = None,
|
|
457
|
+
laddr: Optional[bool] = None,
|
|
458
|
+
user: Optional[str] = None,
|
|
459
|
+
maxage: Optional[int] = None,
|
|
460
460
|
**kwargs,
|
|
461
461
|
) -> ResponseT:
|
|
462
462
|
"""
|
|
@@ -512,7 +512,7 @@ class ManagementCommands(CommandsProtocol):
|
|
|
512
512
|
return self.execute_command("CLIENT INFO", **kwargs)
|
|
513
513
|
|
|
514
514
|
def client_list(
|
|
515
|
-
self, _type:
|
|
515
|
+
self, _type: Optional[str] = None, client_id: List[EncodableT] = [], **kwargs
|
|
516
516
|
) -> ResponseT:
|
|
517
517
|
"""
|
|
518
518
|
Returns a list of currently connected clients.
|
|
@@ -589,7 +589,7 @@ class ManagementCommands(CommandsProtocol):
|
|
|
589
589
|
|
|
590
590
|
def client_tracking_on(
|
|
591
591
|
self,
|
|
592
|
-
clientid:
|
|
592
|
+
clientid: Optional[int] = None,
|
|
593
593
|
prefix: Sequence[KeyT] = [],
|
|
594
594
|
bcast: bool = False,
|
|
595
595
|
optin: bool = False,
|
|
@@ -608,7 +608,7 @@ class ManagementCommands(CommandsProtocol):
|
|
|
608
608
|
|
|
609
609
|
def client_tracking_off(
|
|
610
610
|
self,
|
|
611
|
-
clientid:
|
|
611
|
+
clientid: Optional[int] = None,
|
|
612
612
|
prefix: Sequence[KeyT] = [],
|
|
613
613
|
bcast: bool = False,
|
|
614
614
|
optin: bool = False,
|
|
@@ -628,7 +628,7 @@ class ManagementCommands(CommandsProtocol):
|
|
|
628
628
|
def client_tracking(
|
|
629
629
|
self,
|
|
630
630
|
on: bool = True,
|
|
631
|
-
clientid:
|
|
631
|
+
clientid: Optional[int] = None,
|
|
632
632
|
prefix: Sequence[KeyT] = [],
|
|
633
633
|
bcast: bool = False,
|
|
634
634
|
optin: bool = False,
|
|
@@ -988,7 +988,7 @@ class ManagementCommands(CommandsProtocol):
|
|
|
988
988
|
return self.execute_command("SELECT", index, **kwargs)
|
|
989
989
|
|
|
990
990
|
def info(
|
|
991
|
-
self, section:
|
|
991
|
+
self, section: Optional[str] = None, *args: List[str], **kwargs
|
|
992
992
|
) -> ResponseT:
|
|
993
993
|
"""
|
|
994
994
|
Returns a dictionary containing information about the Redis server
|
|
@@ -1070,7 +1070,7 @@ class ManagementCommands(CommandsProtocol):
|
|
|
1070
1070
|
timeout: int,
|
|
1071
1071
|
copy: bool = False,
|
|
1072
1072
|
replace: bool = False,
|
|
1073
|
-
auth:
|
|
1073
|
+
auth: Optional[str] = None,
|
|
1074
1074
|
**kwargs,
|
|
1075
1075
|
) -> ResponseT:
|
|
1076
1076
|
"""
|
|
@@ -1152,7 +1152,7 @@ class ManagementCommands(CommandsProtocol):
|
|
|
1152
1152
|
return self.execute_command("MEMORY MALLOC-STATS", **kwargs)
|
|
1153
1153
|
|
|
1154
1154
|
def memory_usage(
|
|
1155
|
-
self, key: KeyT, samples:
|
|
1155
|
+
self, key: KeyT, samples: Optional[int] = None, **kwargs
|
|
1156
1156
|
) -> ResponseT:
|
|
1157
1157
|
"""
|
|
1158
1158
|
Return the total memory usage for key, its value and associated
|
|
@@ -1291,7 +1291,7 @@ class ManagementCommands(CommandsProtocol):
|
|
|
1291
1291
|
raise RedisError("SHUTDOWN seems to have failed.")
|
|
1292
1292
|
|
|
1293
1293
|
def slaveof(
|
|
1294
|
-
self, host:
|
|
1294
|
+
self, host: Optional[str] = None, port: Optional[int] = None, **kwargs
|
|
1295
1295
|
) -> ResponseT:
|
|
1296
1296
|
"""
|
|
1297
1297
|
Set the server to be a replicated slave of the instance identified
|
|
@@ -1304,7 +1304,7 @@ class ManagementCommands(CommandsProtocol):
|
|
|
1304
1304
|
return self.execute_command("SLAVEOF", b"NO", b"ONE", **kwargs)
|
|
1305
1305
|
return self.execute_command("SLAVEOF", host, port, **kwargs)
|
|
1306
1306
|
|
|
1307
|
-
def slowlog_get(self, num:
|
|
1307
|
+
def slowlog_get(self, num: Optional[int] = None, **kwargs) -> ResponseT:
|
|
1308
1308
|
"""
|
|
1309
1309
|
Get the entries from the slowlog. If ``num`` is specified, get the
|
|
1310
1310
|
most recent ``num`` items.
|
|
@@ -1451,7 +1451,7 @@ class BitFieldOperation:
|
|
|
1451
1451
|
self,
|
|
1452
1452
|
client: Union["redis.client.Redis", "redis.asyncio.client.Redis"],
|
|
1453
1453
|
key: str,
|
|
1454
|
-
default_overflow:
|
|
1454
|
+
default_overflow: Optional[str] = None,
|
|
1455
1455
|
):
|
|
1456
1456
|
self.client = client
|
|
1457
1457
|
self.key = key
|
|
@@ -1487,7 +1487,7 @@ class BitFieldOperation:
|
|
|
1487
1487
|
fmt: str,
|
|
1488
1488
|
offset: BitfieldOffsetT,
|
|
1489
1489
|
increment: int,
|
|
1490
|
-
overflow:
|
|
1490
|
+
overflow: Optional[str] = None,
|
|
1491
1491
|
):
|
|
1492
1492
|
"""
|
|
1493
1493
|
Increment a bitfield by a given amount.
|
|
@@ -1572,8 +1572,8 @@ class BasicKeyCommands(CommandsProtocol):
|
|
|
1572
1572
|
def bitcount(
|
|
1573
1573
|
self,
|
|
1574
1574
|
key: KeyT,
|
|
1575
|
-
start:
|
|
1576
|
-
end:
|
|
1575
|
+
start: Optional[int] = None,
|
|
1576
|
+
end: Optional[int] = None,
|
|
1577
1577
|
mode: Optional[str] = None,
|
|
1578
1578
|
) -> ResponseT:
|
|
1579
1579
|
"""
|
|
@@ -1595,7 +1595,7 @@ class BasicKeyCommands(CommandsProtocol):
|
|
|
1595
1595
|
def bitfield(
|
|
1596
1596
|
self: Union["redis.client.Redis", "redis.asyncio.client.Redis"],
|
|
1597
1597
|
key: KeyT,
|
|
1598
|
-
default_overflow:
|
|
1598
|
+
default_overflow: Optional[str] = None,
|
|
1599
1599
|
) -> BitFieldOperation:
|
|
1600
1600
|
"""
|
|
1601
1601
|
Return a BitFieldOperation instance to conveniently construct one or
|
|
@@ -1641,8 +1641,8 @@ class BasicKeyCommands(CommandsProtocol):
|
|
|
1641
1641
|
self,
|
|
1642
1642
|
key: KeyT,
|
|
1643
1643
|
bit: int,
|
|
1644
|
-
start:
|
|
1645
|
-
end:
|
|
1644
|
+
start: Optional[int] = None,
|
|
1645
|
+
end: Optional[int] = None,
|
|
1646
1646
|
mode: Optional[str] = None,
|
|
1647
1647
|
) -> ResponseT:
|
|
1648
1648
|
"""
|
|
@@ -1672,7 +1672,7 @@ class BasicKeyCommands(CommandsProtocol):
|
|
|
1672
1672
|
self,
|
|
1673
1673
|
source: str,
|
|
1674
1674
|
destination: str,
|
|
1675
|
-
destination_db:
|
|
1675
|
+
destination_db: Optional[str] = None,
|
|
1676
1676
|
replace: bool = False,
|
|
1677
1677
|
) -> ResponseT:
|
|
1678
1678
|
"""
|
|
@@ -2137,7 +2137,7 @@ class BasicKeyCommands(CommandsProtocol):
|
|
|
2137
2137
|
return self.execute_command("PTTL", name)
|
|
2138
2138
|
|
|
2139
2139
|
def hrandfield(
|
|
2140
|
-
self, key: str, count: int = None, withvalues: bool = False
|
|
2140
|
+
self, key: str, count: Optional[int] = None, withvalues: bool = False
|
|
2141
2141
|
) -> ResponseT:
|
|
2142
2142
|
"""
|
|
2143
2143
|
Return a random field from the hash value stored at key.
|
|
@@ -2191,8 +2191,8 @@ class BasicKeyCommands(CommandsProtocol):
|
|
|
2191
2191
|
value: EncodableT,
|
|
2192
2192
|
replace: bool = False,
|
|
2193
2193
|
absttl: bool = False,
|
|
2194
|
-
idletime:
|
|
2195
|
-
frequency:
|
|
2194
|
+
idletime: Optional[int] = None,
|
|
2195
|
+
frequency: Optional[int] = None,
|
|
2196
2196
|
) -> ResponseT:
|
|
2197
2197
|
"""
|
|
2198
2198
|
Create a key using the provided serialized value, previously obtained
|
|
@@ -2360,7 +2360,7 @@ class BasicKeyCommands(CommandsProtocol):
|
|
|
2360
2360
|
specific_argument: Union[Literal["strings"], Literal["keys"]] = "strings",
|
|
2361
2361
|
len: bool = False,
|
|
2362
2362
|
idx: bool = False,
|
|
2363
|
-
minmatchlen:
|
|
2363
|
+
minmatchlen: Optional[int] = None,
|
|
2364
2364
|
withmatchlen: bool = False,
|
|
2365
2365
|
**kwargs,
|
|
2366
2366
|
) -> ResponseT:
|
|
@@ -2960,8 +2960,8 @@ class ScanCommands(CommandsProtocol):
|
|
|
2960
2960
|
self,
|
|
2961
2961
|
cursor: int = 0,
|
|
2962
2962
|
match: Union[PatternT, None] = None,
|
|
2963
|
-
count:
|
|
2964
|
-
_type:
|
|
2963
|
+
count: Optional[int] = None,
|
|
2964
|
+
_type: Optional[str] = None,
|
|
2965
2965
|
**kwargs,
|
|
2966
2966
|
) -> ResponseT:
|
|
2967
2967
|
"""
|
|
@@ -2992,8 +2992,8 @@ class ScanCommands(CommandsProtocol):
|
|
|
2992
2992
|
def scan_iter(
|
|
2993
2993
|
self,
|
|
2994
2994
|
match: Union[PatternT, None] = None,
|
|
2995
|
-
count:
|
|
2996
|
-
_type:
|
|
2995
|
+
count: Optional[int] = None,
|
|
2996
|
+
_type: Optional[str] = None,
|
|
2997
2997
|
**kwargs,
|
|
2998
2998
|
) -> Iterator:
|
|
2999
2999
|
"""
|
|
@@ -3022,7 +3022,7 @@ class ScanCommands(CommandsProtocol):
|
|
|
3022
3022
|
name: KeyT,
|
|
3023
3023
|
cursor: int = 0,
|
|
3024
3024
|
match: Union[PatternT, None] = None,
|
|
3025
|
-
count:
|
|
3025
|
+
count: Optional[int] = None,
|
|
3026
3026
|
) -> ResponseT:
|
|
3027
3027
|
"""
|
|
3028
3028
|
Incrementally return lists of elements in a set. Also return a cursor
|
|
@@ -3045,7 +3045,7 @@ class ScanCommands(CommandsProtocol):
|
|
|
3045
3045
|
self,
|
|
3046
3046
|
name: KeyT,
|
|
3047
3047
|
match: Union[PatternT, None] = None,
|
|
3048
|
-
count:
|
|
3048
|
+
count: Optional[int] = None,
|
|
3049
3049
|
) -> Iterator:
|
|
3050
3050
|
"""
|
|
3051
3051
|
Make an iterator using the SSCAN command so that the client doesn't
|
|
@@ -3065,7 +3065,7 @@ class ScanCommands(CommandsProtocol):
|
|
|
3065
3065
|
name: KeyT,
|
|
3066
3066
|
cursor: int = 0,
|
|
3067
3067
|
match: Union[PatternT, None] = None,
|
|
3068
|
-
count:
|
|
3068
|
+
count: Optional[int] = None,
|
|
3069
3069
|
no_values: Union[bool, None] = None,
|
|
3070
3070
|
) -> ResponseT:
|
|
3071
3071
|
"""
|
|
@@ -3093,7 +3093,7 @@ class ScanCommands(CommandsProtocol):
|
|
|
3093
3093
|
self,
|
|
3094
3094
|
name: str,
|
|
3095
3095
|
match: Union[PatternT, None] = None,
|
|
3096
|
-
count:
|
|
3096
|
+
count: Optional[int] = None,
|
|
3097
3097
|
no_values: Union[bool, None] = None,
|
|
3098
3098
|
) -> Iterator:
|
|
3099
3099
|
"""
|
|
@@ -3121,7 +3121,7 @@ class ScanCommands(CommandsProtocol):
|
|
|
3121
3121
|
name: KeyT,
|
|
3122
3122
|
cursor: int = 0,
|
|
3123
3123
|
match: Union[PatternT, None] = None,
|
|
3124
|
-
count:
|
|
3124
|
+
count: Optional[int] = None,
|
|
3125
3125
|
score_cast_func: Union[type, Callable] = float,
|
|
3126
3126
|
) -> ResponseT:
|
|
3127
3127
|
"""
|
|
@@ -3148,7 +3148,7 @@ class ScanCommands(CommandsProtocol):
|
|
|
3148
3148
|
self,
|
|
3149
3149
|
name: KeyT,
|
|
3150
3150
|
match: Union[PatternT, None] = None,
|
|
3151
|
-
count:
|
|
3151
|
+
count: Optional[int] = None,
|
|
3152
3152
|
score_cast_func: Union[type, Callable] = float,
|
|
3153
3153
|
) -> Iterator:
|
|
3154
3154
|
"""
|
|
@@ -3177,8 +3177,8 @@ class AsyncScanCommands(ScanCommands):
|
|
|
3177
3177
|
async def scan_iter(
|
|
3178
3178
|
self,
|
|
3179
3179
|
match: Union[PatternT, None] = None,
|
|
3180
|
-
count:
|
|
3181
|
-
_type:
|
|
3180
|
+
count: Optional[int] = None,
|
|
3181
|
+
_type: Optional[str] = None,
|
|
3182
3182
|
**kwargs,
|
|
3183
3183
|
) -> AsyncIterator:
|
|
3184
3184
|
"""
|
|
@@ -3207,7 +3207,7 @@ class AsyncScanCommands(ScanCommands):
|
|
|
3207
3207
|
self,
|
|
3208
3208
|
name: KeyT,
|
|
3209
3209
|
match: Union[PatternT, None] = None,
|
|
3210
|
-
count:
|
|
3210
|
+
count: Optional[int] = None,
|
|
3211
3211
|
) -> AsyncIterator:
|
|
3212
3212
|
"""
|
|
3213
3213
|
Make an iterator using the SSCAN command so that the client doesn't
|
|
@@ -3229,7 +3229,7 @@ class AsyncScanCommands(ScanCommands):
|
|
|
3229
3229
|
self,
|
|
3230
3230
|
name: str,
|
|
3231
3231
|
match: Union[PatternT, None] = None,
|
|
3232
|
-
count:
|
|
3232
|
+
count: Optional[int] = None,
|
|
3233
3233
|
no_values: Union[bool, None] = None,
|
|
3234
3234
|
) -> AsyncIterator:
|
|
3235
3235
|
"""
|
|
@@ -3258,7 +3258,7 @@ class AsyncScanCommands(ScanCommands):
|
|
|
3258
3258
|
self,
|
|
3259
3259
|
name: KeyT,
|
|
3260
3260
|
match: Union[PatternT, None] = None,
|
|
3261
|
-
count:
|
|
3261
|
+
count: Optional[int] = None,
|
|
3262
3262
|
score_cast_func: Union[type, Callable] = float,
|
|
3263
3263
|
) -> AsyncIterator:
|
|
3264
3264
|
"""
|
|
@@ -3489,11 +3489,11 @@ class StreamCommands(CommandsProtocol):
|
|
|
3489
3489
|
name: KeyT,
|
|
3490
3490
|
fields: Dict[FieldT, EncodableT],
|
|
3491
3491
|
id: StreamIdT = "*",
|
|
3492
|
-
maxlen:
|
|
3492
|
+
maxlen: Optional[int] = None,
|
|
3493
3493
|
approximate: bool = True,
|
|
3494
3494
|
nomkstream: bool = False,
|
|
3495
3495
|
minid: Union[StreamIdT, None] = None,
|
|
3496
|
-
limit:
|
|
3496
|
+
limit: Optional[int] = None,
|
|
3497
3497
|
) -> ResponseT:
|
|
3498
3498
|
"""
|
|
3499
3499
|
Add to a stream.
|
|
@@ -3544,7 +3544,7 @@ class StreamCommands(CommandsProtocol):
|
|
|
3544
3544
|
consumername: ConsumerT,
|
|
3545
3545
|
min_idle_time: int,
|
|
3546
3546
|
start_id: StreamIdT = "0-0",
|
|
3547
|
-
count:
|
|
3547
|
+
count: Optional[int] = None,
|
|
3548
3548
|
justid: bool = False,
|
|
3549
3549
|
) -> ResponseT:
|
|
3550
3550
|
"""
|
|
@@ -3595,9 +3595,9 @@ class StreamCommands(CommandsProtocol):
|
|
|
3595
3595
|
consumername: ConsumerT,
|
|
3596
3596
|
min_idle_time: int,
|
|
3597
3597
|
message_ids: Union[List[StreamIdT], Tuple[StreamIdT]],
|
|
3598
|
-
idle:
|
|
3599
|
-
time:
|
|
3600
|
-
retrycount:
|
|
3598
|
+
idle: Optional[int] = None,
|
|
3599
|
+
time: Optional[int] = None,
|
|
3600
|
+
retrycount: Optional[int] = None,
|
|
3601
3601
|
force: bool = False,
|
|
3602
3602
|
justid: bool = False,
|
|
3603
3603
|
) -> ResponseT:
|
|
@@ -3829,7 +3829,7 @@ class StreamCommands(CommandsProtocol):
|
|
|
3829
3829
|
max: StreamIdT,
|
|
3830
3830
|
count: int,
|
|
3831
3831
|
consumername: Union[ConsumerT, None] = None,
|
|
3832
|
-
idle:
|
|
3832
|
+
idle: Optional[int] = None,
|
|
3833
3833
|
) -> ResponseT:
|
|
3834
3834
|
"""
|
|
3835
3835
|
Returns information about pending messages, in a range.
|
|
@@ -3883,7 +3883,7 @@ class StreamCommands(CommandsProtocol):
|
|
|
3883
3883
|
name: KeyT,
|
|
3884
3884
|
min: StreamIdT = "-",
|
|
3885
3885
|
max: StreamIdT = "+",
|
|
3886
|
-
count:
|
|
3886
|
+
count: Optional[int] = None,
|
|
3887
3887
|
) -> ResponseT:
|
|
3888
3888
|
"""
|
|
3889
3889
|
Read stream values within an interval.
|
|
@@ -3913,8 +3913,8 @@ class StreamCommands(CommandsProtocol):
|
|
|
3913
3913
|
def xread(
|
|
3914
3914
|
self,
|
|
3915
3915
|
streams: Dict[KeyT, StreamIdT],
|
|
3916
|
-
count:
|
|
3917
|
-
block:
|
|
3916
|
+
count: Optional[int] = None,
|
|
3917
|
+
block: Optional[int] = None,
|
|
3918
3918
|
) -> ResponseT:
|
|
3919
3919
|
"""
|
|
3920
3920
|
Block and monitor multiple streams for new data.
|
|
@@ -3953,8 +3953,8 @@ class StreamCommands(CommandsProtocol):
|
|
|
3953
3953
|
groupname: str,
|
|
3954
3954
|
consumername: str,
|
|
3955
3955
|
streams: Dict[KeyT, StreamIdT],
|
|
3956
|
-
count:
|
|
3957
|
-
block:
|
|
3956
|
+
count: Optional[int] = None,
|
|
3957
|
+
block: Optional[int] = None,
|
|
3958
3958
|
noack: bool = False,
|
|
3959
3959
|
) -> ResponseT:
|
|
3960
3960
|
"""
|
|
@@ -4000,7 +4000,7 @@ class StreamCommands(CommandsProtocol):
|
|
|
4000
4000
|
name: KeyT,
|
|
4001
4001
|
max: StreamIdT = "+",
|
|
4002
4002
|
min: StreamIdT = "-",
|
|
4003
|
-
count:
|
|
4003
|
+
count: Optional[int] = None,
|
|
4004
4004
|
) -> ResponseT:
|
|
4005
4005
|
"""
|
|
4006
4006
|
Read stream values within an interval, in reverse order.
|
|
@@ -4030,10 +4030,10 @@ class StreamCommands(CommandsProtocol):
|
|
|
4030
4030
|
def xtrim(
|
|
4031
4031
|
self,
|
|
4032
4032
|
name: KeyT,
|
|
4033
|
-
maxlen:
|
|
4033
|
+
maxlen: Optional[int] = None,
|
|
4034
4034
|
approximate: bool = True,
|
|
4035
4035
|
minid: Union[StreamIdT, None] = None,
|
|
4036
|
-
limit:
|
|
4036
|
+
limit: Optional[int] = None,
|
|
4037
4037
|
) -> ResponseT:
|
|
4038
4038
|
"""
|
|
4039
4039
|
Trims old messages from a stream.
|
|
@@ -4205,7 +4205,7 @@ class SortedSetCommands(CommandsProtocol):
|
|
|
4205
4205
|
return self.execute_command("ZINCRBY", name, amount, value)
|
|
4206
4206
|
|
|
4207
4207
|
def zinter(
|
|
4208
|
-
self, keys: KeysT, aggregate:
|
|
4208
|
+
self, keys: KeysT, aggregate: Optional[str] = None, withscores: bool = False
|
|
4209
4209
|
) -> ResponseT:
|
|
4210
4210
|
"""
|
|
4211
4211
|
Return the intersect of multiple sorted sets specified by ``keys``.
|
|
@@ -4224,7 +4224,7 @@ class SortedSetCommands(CommandsProtocol):
|
|
|
4224
4224
|
self,
|
|
4225
4225
|
dest: KeyT,
|
|
4226
4226
|
keys: Union[Sequence[KeyT], Mapping[AnyKeyT, float]],
|
|
4227
|
-
aggregate:
|
|
4227
|
+
aggregate: Optional[str] = None,
|
|
4228
4228
|
) -> ResponseT:
|
|
4229
4229
|
"""
|
|
4230
4230
|
Intersect multiple sorted sets specified by ``keys`` into a new
|
|
@@ -4263,7 +4263,7 @@ class SortedSetCommands(CommandsProtocol):
|
|
|
4263
4263
|
"""
|
|
4264
4264
|
return self.execute_command("ZLEXCOUNT", name, min, max, keys=[name])
|
|
4265
4265
|
|
|
4266
|
-
def zpopmax(self, name: KeyT, count:
|
|
4266
|
+
def zpopmax(self, name: KeyT, count: Optional[int] = None) -> ResponseT:
|
|
4267
4267
|
"""
|
|
4268
4268
|
Remove and return up to ``count`` members with the highest scores
|
|
4269
4269
|
from the sorted set ``name``.
|
|
@@ -4274,7 +4274,7 @@ class SortedSetCommands(CommandsProtocol):
|
|
|
4274
4274
|
options = {"withscores": True}
|
|
4275
4275
|
return self.execute_command("ZPOPMAX", name, *args, **options)
|
|
4276
4276
|
|
|
4277
|
-
def zpopmin(self, name: KeyT, count:
|
|
4277
|
+
def zpopmin(self, name: KeyT, count: Optional[int] = None) -> ResponseT:
|
|
4278
4278
|
"""
|
|
4279
4279
|
Remove and return up to ``count`` members with the lowest scores
|
|
4280
4280
|
from the sorted set ``name``.
|
|
@@ -4286,7 +4286,7 @@ class SortedSetCommands(CommandsProtocol):
|
|
|
4286
4286
|
return self.execute_command("ZPOPMIN", name, *args, **options)
|
|
4287
4287
|
|
|
4288
4288
|
def zrandmember(
|
|
4289
|
-
self, key: KeyT, count: int = None, withscores: bool = False
|
|
4289
|
+
self, key: KeyT, count: Optional[int] = None, withscores: bool = False
|
|
4290
4290
|
) -> ResponseT:
|
|
4291
4291
|
"""
|
|
4292
4292
|
Return a random element from the sorted set value stored at key.
|
|
@@ -4418,8 +4418,8 @@ class SortedSetCommands(CommandsProtocol):
|
|
|
4418
4418
|
bylex: bool = False,
|
|
4419
4419
|
withscores: bool = False,
|
|
4420
4420
|
score_cast_func: Union[type, Callable, None] = float,
|
|
4421
|
-
offset:
|
|
4422
|
-
num:
|
|
4421
|
+
offset: Optional[int] = None,
|
|
4422
|
+
num: Optional[int] = None,
|
|
4423
4423
|
) -> ResponseT:
|
|
4424
4424
|
if byscore and bylex:
|
|
4425
4425
|
raise DataError("``byscore`` and ``bylex`` can not be specified together.")
|
|
@@ -4457,8 +4457,8 @@ class SortedSetCommands(CommandsProtocol):
|
|
|
4457
4457
|
score_cast_func: Union[type, Callable] = float,
|
|
4458
4458
|
byscore: bool = False,
|
|
4459
4459
|
bylex: bool = False,
|
|
4460
|
-
offset: int = None,
|
|
4461
|
-
num: int = None,
|
|
4460
|
+
offset: Optional[int] = None,
|
|
4461
|
+
num: Optional[int] = None,
|
|
4462
4462
|
) -> ResponseT:
|
|
4463
4463
|
"""
|
|
4464
4464
|
Return a range of values from sorted set ``name`` between
|
|
@@ -4545,8 +4545,8 @@ class SortedSetCommands(CommandsProtocol):
|
|
|
4545
4545
|
byscore: bool = False,
|
|
4546
4546
|
bylex: bool = False,
|
|
4547
4547
|
desc: bool = False,
|
|
4548
|
-
offset:
|
|
4549
|
-
num:
|
|
4548
|
+
offset: Optional[int] = None,
|
|
4549
|
+
num: Optional[int] = None,
|
|
4550
4550
|
) -> ResponseT:
|
|
4551
4551
|
"""
|
|
4552
4552
|
Stores in ``dest`` the result of a range of values from sorted set
|
|
@@ -4591,8 +4591,8 @@ class SortedSetCommands(CommandsProtocol):
|
|
|
4591
4591
|
name: KeyT,
|
|
4592
4592
|
min: EncodableT,
|
|
4593
4593
|
max: EncodableT,
|
|
4594
|
-
start:
|
|
4595
|
-
num:
|
|
4594
|
+
start: Optional[int] = None,
|
|
4595
|
+
num: Optional[int] = None,
|
|
4596
4596
|
) -> ResponseT:
|
|
4597
4597
|
"""
|
|
4598
4598
|
Return the lexicographical range of values from sorted set ``name``
|
|
@@ -4615,8 +4615,8 @@ class SortedSetCommands(CommandsProtocol):
|
|
|
4615
4615
|
name: KeyT,
|
|
4616
4616
|
max: EncodableT,
|
|
4617
4617
|
min: EncodableT,
|
|
4618
|
-
start:
|
|
4619
|
-
num:
|
|
4618
|
+
start: Optional[int] = None,
|
|
4619
|
+
num: Optional[int] = None,
|
|
4620
4620
|
) -> ResponseT:
|
|
4621
4621
|
"""
|
|
4622
4622
|
Return the reversed lexicographical range of values from sorted set
|
|
@@ -4639,8 +4639,8 @@ class SortedSetCommands(CommandsProtocol):
|
|
|
4639
4639
|
name: KeyT,
|
|
4640
4640
|
min: ZScoreBoundT,
|
|
4641
4641
|
max: ZScoreBoundT,
|
|
4642
|
-
start:
|
|
4643
|
-
num:
|
|
4642
|
+
start: Optional[int] = None,
|
|
4643
|
+
num: Optional[int] = None,
|
|
4644
4644
|
withscores: bool = False,
|
|
4645
4645
|
score_cast_func: Union[type, Callable] = float,
|
|
4646
4646
|
) -> ResponseT:
|
|
@@ -4674,8 +4674,8 @@ class SortedSetCommands(CommandsProtocol):
|
|
|
4674
4674
|
name: KeyT,
|
|
4675
4675
|
max: ZScoreBoundT,
|
|
4676
4676
|
min: ZScoreBoundT,
|
|
4677
|
-
start:
|
|
4678
|
-
num:
|
|
4677
|
+
start: Optional[int] = None,
|
|
4678
|
+
num: Optional[int] = None,
|
|
4679
4679
|
withscores: bool = False,
|
|
4680
4680
|
score_cast_func: Union[type, Callable] = float,
|
|
4681
4681
|
):
|
|
@@ -4794,7 +4794,7 @@ class SortedSetCommands(CommandsProtocol):
|
|
|
4794
4794
|
def zunion(
|
|
4795
4795
|
self,
|
|
4796
4796
|
keys: Union[Sequence[KeyT], Mapping[AnyKeyT, float]],
|
|
4797
|
-
aggregate:
|
|
4797
|
+
aggregate: Optional[str] = None,
|
|
4798
4798
|
withscores: bool = False,
|
|
4799
4799
|
) -> ResponseT:
|
|
4800
4800
|
"""
|
|
@@ -4811,7 +4811,7 @@ class SortedSetCommands(CommandsProtocol):
|
|
|
4811
4811
|
self,
|
|
4812
4812
|
dest: KeyT,
|
|
4813
4813
|
keys: Union[Sequence[KeyT], Mapping[AnyKeyT, float]],
|
|
4814
|
-
aggregate:
|
|
4814
|
+
aggregate: Optional[str] = None,
|
|
4815
4815
|
) -> ResponseT:
|
|
4816
4816
|
"""
|
|
4817
4817
|
Union multiple sorted sets specified by ``keys`` into
|
|
@@ -4843,7 +4843,7 @@ class SortedSetCommands(CommandsProtocol):
|
|
|
4843
4843
|
command: str,
|
|
4844
4844
|
dest: Union[KeyT, None],
|
|
4845
4845
|
keys: Union[Sequence[KeyT], Mapping[AnyKeyT, float]],
|
|
4846
|
-
aggregate:
|
|
4846
|
+
aggregate: Optional[str] = None,
|
|
4847
4847
|
**options,
|
|
4848
4848
|
) -> ResponseT:
|
|
4849
4849
|
pieces: list[EncodableT] = [command]
|
|
@@ -5994,7 +5994,7 @@ class GeoCommands(CommandsProtocol):
|
|
|
5994
5994
|
return self.execute_command("GEOADD", *pieces)
|
|
5995
5995
|
|
|
5996
5996
|
def geodist(
|
|
5997
|
-
self, name: KeyT, place1: FieldT, place2: FieldT, unit:
|
|
5997
|
+
self, name: KeyT, place1: FieldT, place2: FieldT, unit: Optional[str] = None
|
|
5998
5998
|
) -> ResponseT:
|
|
5999
5999
|
"""
|
|
6000
6000
|
Return the distance between ``place1`` and ``place2`` members of the
|
|
@@ -6036,14 +6036,14 @@ class GeoCommands(CommandsProtocol):
|
|
|
6036
6036
|
longitude: float,
|
|
6037
6037
|
latitude: float,
|
|
6038
6038
|
radius: float,
|
|
6039
|
-
unit:
|
|
6039
|
+
unit: Optional[str] = None,
|
|
6040
6040
|
withdist: bool = False,
|
|
6041
6041
|
withcoord: bool = False,
|
|
6042
6042
|
withhash: bool = False,
|
|
6043
|
-
count:
|
|
6044
|
-
sort:
|
|
6045
|
-
store:
|
|
6046
|
-
store_dist:
|
|
6043
|
+
count: Optional[int] = None,
|
|
6044
|
+
sort: Optional[str] = None,
|
|
6045
|
+
store: Optional[KeyT] = None,
|
|
6046
|
+
store_dist: Optional[KeyT] = None,
|
|
6047
6047
|
any: bool = False,
|
|
6048
6048
|
) -> ResponseT:
|
|
6049
6049
|
"""
|
|
@@ -6098,12 +6098,12 @@ class GeoCommands(CommandsProtocol):
|
|
|
6098
6098
|
name: KeyT,
|
|
6099
6099
|
member: FieldT,
|
|
6100
6100
|
radius: float,
|
|
6101
|
-
unit:
|
|
6101
|
+
unit: Optional[str] = None,
|
|
6102
6102
|
withdist: bool = False,
|
|
6103
6103
|
withcoord: bool = False,
|
|
6104
6104
|
withhash: bool = False,
|
|
6105
|
-
count:
|
|
6106
|
-
sort:
|
|
6105
|
+
count: Optional[int] = None,
|
|
6106
|
+
sort: Optional[str] = None,
|
|
6107
6107
|
store: Union[KeyT, None] = None,
|
|
6108
6108
|
store_dist: Union[KeyT, None] = None,
|
|
6109
6109
|
any: bool = False,
|
|
@@ -6188,8 +6188,8 @@ class GeoCommands(CommandsProtocol):
|
|
|
6188
6188
|
radius: Union[float, None] = None,
|
|
6189
6189
|
width: Union[float, None] = None,
|
|
6190
6190
|
height: Union[float, None] = None,
|
|
6191
|
-
sort:
|
|
6192
|
-
count:
|
|
6191
|
+
sort: Optional[str] = None,
|
|
6192
|
+
count: Optional[int] = None,
|
|
6193
6193
|
any: bool = False,
|
|
6194
6194
|
withcoord: bool = False,
|
|
6195
6195
|
withdist: bool = False,
|
|
@@ -6263,15 +6263,15 @@ class GeoCommands(CommandsProtocol):
|
|
|
6263
6263
|
self,
|
|
6264
6264
|
dest: KeyT,
|
|
6265
6265
|
name: KeyT,
|
|
6266
|
-
member:
|
|
6267
|
-
longitude:
|
|
6268
|
-
latitude:
|
|
6266
|
+
member: Optional[FieldT] = None,
|
|
6267
|
+
longitude: Optional[float] = None,
|
|
6268
|
+
latitude: Optional[float] = None,
|
|
6269
6269
|
unit: str = "m",
|
|
6270
|
-
radius:
|
|
6271
|
-
width:
|
|
6272
|
-
height:
|
|
6273
|
-
sort:
|
|
6274
|
-
count:
|
|
6270
|
+
radius: Optional[float] = None,
|
|
6271
|
+
width: Optional[float] = None,
|
|
6272
|
+
height: Optional[float] = None,
|
|
6273
|
+
sort: Optional[str] = None,
|
|
6274
|
+
count: Optional[int] = None,
|
|
6275
6275
|
any: bool = False,
|
|
6276
6276
|
storedist: bool = False,
|
|
6277
6277
|
) -> ResponseT:
|
redis/commands/helpers.py
CHANGED
|
@@ -43,19 +43,32 @@ def parse_to_list(response):
|
|
|
43
43
|
"""Optimistically parse the response to a list."""
|
|
44
44
|
res = []
|
|
45
45
|
|
|
46
|
+
special_values = {"infinity", "nan", "-infinity"}
|
|
47
|
+
|
|
46
48
|
if response is None:
|
|
47
49
|
return res
|
|
48
50
|
|
|
49
51
|
for item in response:
|
|
52
|
+
if item is None:
|
|
53
|
+
res.append(None)
|
|
54
|
+
continue
|
|
50
55
|
try:
|
|
51
|
-
|
|
52
|
-
except ValueError:
|
|
53
|
-
try:
|
|
54
|
-
res.append(float(item))
|
|
55
|
-
except ValueError:
|
|
56
|
-
res.append(nativestr(item))
|
|
56
|
+
item_str = nativestr(item)
|
|
57
57
|
except TypeError:
|
|
58
58
|
res.append(None)
|
|
59
|
+
continue
|
|
60
|
+
|
|
61
|
+
if isinstance(item_str, str) and item_str.lower() in special_values:
|
|
62
|
+
res.append(item_str) # Keep as string
|
|
63
|
+
else:
|
|
64
|
+
try:
|
|
65
|
+
res.append(int(item))
|
|
66
|
+
except ValueError:
|
|
67
|
+
try:
|
|
68
|
+
res.append(float(item))
|
|
69
|
+
except ValueError:
|
|
70
|
+
res.append(item_str)
|
|
71
|
+
|
|
59
72
|
return res
|
|
60
73
|
|
|
61
74
|
|