valkey-glide 2.0.0rc7__cp39-cp39-macosx_11_0_arm64.whl → 2.1.0rc1__cp39-cp39-macosx_11_0_arm64.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.
Potentially problematic release.
This version of valkey-glide might be problematic. Click here for more details.
- glide/__init__.py +103 -107
- glide/async_commands/cluster_commands.py +83 -101
- glide/async_commands/core.py +554 -424
- glide/async_commands/{server_modules/ft.py → ft.py} +8 -7
- glide/async_commands/{server_modules/glide_json.py → glide_json.py} +15 -92
- glide/async_commands/standalone_commands.py +18 -17
- glide/glide.cpython-39-darwin.so +0 -0
- glide/glide.pyi +26 -1
- glide/glide_client.py +70 -45
- glide/logger.py +33 -21
- glide/opentelemetry.py +185 -0
- glide_shared/__init__.py +326 -0
- {glide/async_commands → glide_shared/commands}/batch.py +411 -18
- glide_shared/commands/batch_options.py +261 -0
- glide_shared/commands/core_options.py +407 -0
- {glide/async_commands → glide_shared/commands}/server_modules/ft_options/ft_aggregate_options.py +3 -3
- {glide/async_commands → glide_shared/commands}/server_modules/ft_options/ft_create_options.py +4 -2
- {glide/async_commands → glide_shared/commands}/server_modules/ft_options/ft_profile_options.py +4 -4
- {glide/async_commands → glide_shared/commands}/server_modules/ft_options/ft_search_options.py +4 -2
- {glide/async_commands → glide_shared/commands}/server_modules/json_batch.py +4 -4
- glide_shared/commands/server_modules/json_options.py +93 -0
- {glide/async_commands → glide_shared/commands}/sorted_set.py +2 -2
- {glide/async_commands → glide_shared/commands}/stream.py +1 -1
- {glide → glide_shared}/config.py +120 -32
- {glide → glide_shared}/constants.py +3 -3
- {glide → glide_shared}/exceptions.py +27 -1
- glide_shared/protobuf/command_request_pb2.py +54 -0
- glide_shared/protobuf/connection_request_pb2.py +52 -0
- {glide → glide_shared}/protobuf/response_pb2.py +6 -6
- {glide → glide_shared}/routes.py +29 -15
- valkey_glide-2.1.0rc1.dist-info/METADATA +210 -0
- valkey_glide-2.1.0rc1.dist-info/RECORD +39 -0
- glide/protobuf/command_request_pb2.py +0 -54
- glide/protobuf/command_request_pb2.pyi +0 -1187
- glide/protobuf/connection_request_pb2.py +0 -54
- glide/protobuf/connection_request_pb2.pyi +0 -320
- glide/protobuf/response_pb2.pyi +0 -100
- valkey_glide-2.0.0rc7.dist-info/METADATA +0 -144
- valkey_glide-2.0.0rc7.dist-info/RECORD +0 -37
- /glide/py.typed → /glide_shared/commands/__init__.py +0 -0
- {glide/async_commands → glide_shared/commands}/bitmap.py +0 -0
- {glide/async_commands → glide_shared/commands}/command_args.py +0 -0
- {glide/async_commands → glide_shared/commands}/server_modules/ft_options/ft_constants.py +0 -0
- {glide → glide_shared}/protobuf_codec.py +0 -0
- {valkey_glide-2.0.0rc7.dist-info → valkey_glide-2.1.0rc1.dist-info}/WHEEL +0 -0
|
@@ -4,7 +4,7 @@ import sys
|
|
|
4
4
|
import threading
|
|
5
5
|
from typing import List, Mapping, Optional, Tuple, TypeVar, Union
|
|
6
6
|
|
|
7
|
-
from
|
|
7
|
+
from glide_shared.commands.bitmap import (
|
|
8
8
|
BitFieldGet,
|
|
9
9
|
BitFieldSubCommands,
|
|
10
10
|
BitwiseOperation,
|
|
@@ -12,26 +12,27 @@ from glide.async_commands.bitmap import (
|
|
|
12
12
|
_create_bitfield_args,
|
|
13
13
|
_create_bitfield_read_only_args,
|
|
14
14
|
)
|
|
15
|
-
from
|
|
16
|
-
from
|
|
15
|
+
from glide_shared.commands.command_args import Limit, ListDirection, OrderBy
|
|
16
|
+
from glide_shared.commands.core_options import (
|
|
17
17
|
ConditionalChange,
|
|
18
18
|
ExpireOptions,
|
|
19
19
|
ExpiryGetEx,
|
|
20
20
|
ExpirySet,
|
|
21
21
|
FlushMode,
|
|
22
22
|
FunctionRestorePolicy,
|
|
23
|
-
|
|
24
|
-
GeoUnit,
|
|
23
|
+
HashFieldConditionalChange,
|
|
25
24
|
InfoSection,
|
|
26
25
|
InsertPosition,
|
|
27
26
|
UpdateOptions,
|
|
28
27
|
_build_sort_args,
|
|
29
28
|
)
|
|
30
|
-
from
|
|
29
|
+
from glide_shared.commands.sorted_set import (
|
|
31
30
|
AggregationType,
|
|
32
31
|
GeoSearchByBox,
|
|
33
32
|
GeoSearchByRadius,
|
|
34
33
|
GeoSearchCount,
|
|
34
|
+
GeospatialData,
|
|
35
|
+
GeoUnit,
|
|
35
36
|
InfBound,
|
|
36
37
|
LexBoundary,
|
|
37
38
|
RangeByIndex,
|
|
@@ -43,7 +44,7 @@ from glide.async_commands.sorted_set import (
|
|
|
43
44
|
_create_zinter_zunion_cmd_args,
|
|
44
45
|
_create_zrange_args,
|
|
45
46
|
)
|
|
46
|
-
from
|
|
47
|
+
from glide_shared.commands.stream import (
|
|
47
48
|
StreamAddOptions,
|
|
48
49
|
StreamClaimOptions,
|
|
49
50
|
StreamGroupOptions,
|
|
@@ -54,8 +55,9 @@ from glide.async_commands.stream import (
|
|
|
54
55
|
StreamTrimOptions,
|
|
55
56
|
_create_xpending_range_args,
|
|
56
57
|
)
|
|
57
|
-
from
|
|
58
|
-
from
|
|
58
|
+
from glide_shared.constants import TEncodable
|
|
59
|
+
from glide_shared.exceptions import RequestError
|
|
60
|
+
from glide_shared.protobuf.command_request_pb2 import RequestType
|
|
59
61
|
|
|
60
62
|
if sys.version_info >= (3, 13):
|
|
61
63
|
from warnings import deprecated
|
|
@@ -955,6 +957,391 @@ class BaseBatch:
|
|
|
955
957
|
"""
|
|
956
958
|
return self.append_command(RequestType.HStrlen, [key, field])
|
|
957
959
|
|
|
960
|
+
def httl(self: TBatch, key: TEncodable, fields: List[TEncodable]) -> TBatch:
|
|
961
|
+
"""
|
|
962
|
+
Returns the remaining time to live (in seconds) of hash key's field(s) that have an associated expiration.
|
|
963
|
+
|
|
964
|
+
See [valkey.io](https://valkey.io/commands/httl/) for more details.
|
|
965
|
+
|
|
966
|
+
Args:
|
|
967
|
+
key (TEncodable): The key of the hash.
|
|
968
|
+
fields (List[TEncodable]): The list of fields to get TTL for.
|
|
969
|
+
|
|
970
|
+
Commands response:
|
|
971
|
+
List[int]: A list of TTL values for each field:
|
|
972
|
+
- Positive integer: remaining TTL in seconds
|
|
973
|
+
- `-1`: field exists but has no expiration
|
|
974
|
+
- `-2`: field does not exist or key does not exist
|
|
975
|
+
|
|
976
|
+
Since: Valkey 9.0.0
|
|
977
|
+
"""
|
|
978
|
+
return self.append_command(
|
|
979
|
+
RequestType.HTtl, [key, "FIELDS", str(len(fields))] + fields
|
|
980
|
+
)
|
|
981
|
+
|
|
982
|
+
def hpttl(self: TBatch, key: TEncodable, fields: List[TEncodable]) -> TBatch:
|
|
983
|
+
"""
|
|
984
|
+
Returns the remaining time to live (in milliseconds) of hash key's field(s) that have an associated expiration.
|
|
985
|
+
|
|
986
|
+
See [valkey.io](https://valkey.io/commands/hpttl/) for more details.
|
|
987
|
+
|
|
988
|
+
Args:
|
|
989
|
+
key (TEncodable): The key of the hash.
|
|
990
|
+
fields (List[TEncodable]): The list of fields to get TTL for.
|
|
991
|
+
|
|
992
|
+
Commands response:
|
|
993
|
+
List[int]: A list of TTL values for each field:
|
|
994
|
+
- Positive integer: remaining TTL in milliseconds
|
|
995
|
+
- `-1`: field exists but has no expiration
|
|
996
|
+
- `-2`: field does not exist or key does not exist
|
|
997
|
+
|
|
998
|
+
Since: Valkey 9.0.0
|
|
999
|
+
"""
|
|
1000
|
+
return self.append_command(
|
|
1001
|
+
RequestType.HPTtl, [key, "FIELDS", str(len(fields))] + fields
|
|
1002
|
+
)
|
|
1003
|
+
|
|
1004
|
+
def hexpiretime(self: TBatch, key: TEncodable, fields: List[TEncodable]) -> TBatch:
|
|
1005
|
+
"""
|
|
1006
|
+
Returns the expiration Unix timestamp (in seconds) of hash key's field(s) that have an associated expiration.
|
|
1007
|
+
|
|
1008
|
+
See [valkey.io](https://valkey.io/commands/hexpiretime/) for more details.
|
|
1009
|
+
|
|
1010
|
+
Args:
|
|
1011
|
+
key (TEncodable): The key of the hash.
|
|
1012
|
+
fields (List[TEncodable]): The list of fields to get expiration timestamps for.
|
|
1013
|
+
|
|
1014
|
+
Commands response:
|
|
1015
|
+
List[int]: A list of expiration timestamps for each field:
|
|
1016
|
+
- Positive integer: absolute expiration timestamp in seconds (Unix timestamp)
|
|
1017
|
+
- `-1`: field exists but has no expiration
|
|
1018
|
+
- `-2`: field does not exist or key does not exist
|
|
1019
|
+
|
|
1020
|
+
Since: Valkey 9.0.0
|
|
1021
|
+
"""
|
|
1022
|
+
return self.append_command(
|
|
1023
|
+
RequestType.HExpireTime, [key, "FIELDS", str(len(fields))] + fields
|
|
1024
|
+
)
|
|
1025
|
+
|
|
1026
|
+
def hpexpiretime(self: TBatch, key: TEncodable, fields: List[TEncodable]) -> TBatch:
|
|
1027
|
+
"""
|
|
1028
|
+
Returns the expiration Unix timestamp (in milliseconds) of hash key's field(s) that have an associated expiration.
|
|
1029
|
+
|
|
1030
|
+
See [valkey.io](https://valkey.io/commands/hpexpiretime/) for more details.
|
|
1031
|
+
|
|
1032
|
+
Args:
|
|
1033
|
+
key (TEncodable): The key of the hash.
|
|
1034
|
+
fields (List[TEncodable]): The list of fields to get expiration timestamps for.
|
|
1035
|
+
|
|
1036
|
+
Returns:
|
|
1037
|
+
TBatch: The batch object for method chaining.
|
|
1038
|
+
|
|
1039
|
+
Command Response:
|
|
1040
|
+
List[int]: A list of expiration timestamps for each field:
|
|
1041
|
+
- Positive integer: absolute expiration timestamp in milliseconds (Unix timestamp in ms)
|
|
1042
|
+
- `-1`: field exists but has no expiration
|
|
1043
|
+
- `-2`: field does not exist or key does not exist
|
|
1044
|
+
|
|
1045
|
+
Since: Valkey 9.0.0
|
|
1046
|
+
"""
|
|
1047
|
+
return self.append_command(
|
|
1048
|
+
RequestType.HPExpireTime, [key, "FIELDS", str(len(fields))] + fields
|
|
1049
|
+
)
|
|
1050
|
+
|
|
1051
|
+
def hsetex(
|
|
1052
|
+
self: TBatch,
|
|
1053
|
+
key: TEncodable,
|
|
1054
|
+
field_value_map: Mapping[TEncodable, TEncodable],
|
|
1055
|
+
field_conditional_change: Optional[HashFieldConditionalChange] = None,
|
|
1056
|
+
expiry: Optional[ExpirySet] = None,
|
|
1057
|
+
) -> TBatch:
|
|
1058
|
+
"""
|
|
1059
|
+
Sets the specified fields to their respective values in the hash stored at `key` with optional expiration.
|
|
1060
|
+
|
|
1061
|
+
See [valkey.io](https://valkey.io/commands/hsetex/) for more details.
|
|
1062
|
+
|
|
1063
|
+
Args:
|
|
1064
|
+
key (TEncodable): The key of the hash.
|
|
1065
|
+
field_value_map (Mapping[TEncodable, TEncodable]): A field-value map consisting of fields and their corresponding
|
|
1066
|
+
values to be set in the hash stored at the specified key.
|
|
1067
|
+
field_conditional_change (Optional[HashFieldConditionalChange]): Field conditional change option:
|
|
1068
|
+
- ONLY_IF_ALL_EXIST (FXX): Only set fields if all of them already exist.
|
|
1069
|
+
- ONLY_IF_NONE_EXIST (FNX): Only set fields if none of them already exist.
|
|
1070
|
+
expiry (Optional[ExpirySet]): Expiration options for the fields:
|
|
1071
|
+
- EX: Expiration time in seconds.
|
|
1072
|
+
- PX: Expiration time in milliseconds.
|
|
1073
|
+
- EXAT: Absolute expiration time in seconds (Unix timestamp).
|
|
1074
|
+
- PXAT: Absolute expiration time in milliseconds (Unix timestamp).
|
|
1075
|
+
- KEEPTTL: Retain existing TTL.
|
|
1076
|
+
|
|
1077
|
+
Commands response:
|
|
1078
|
+
int: 1 if all fields were set successfully, 0 if none were set due to conditional constraints.
|
|
1079
|
+
|
|
1080
|
+
Since: Valkey 9.0.0
|
|
1081
|
+
"""
|
|
1082
|
+
args: List[TEncodable] = [key]
|
|
1083
|
+
|
|
1084
|
+
# Add field conditional change option if specified
|
|
1085
|
+
if field_conditional_change is not None:
|
|
1086
|
+
args.append(field_conditional_change.value)
|
|
1087
|
+
|
|
1088
|
+
# Add expiry options if specified
|
|
1089
|
+
if expiry is not None:
|
|
1090
|
+
args.extend(expiry.get_cmd_args())
|
|
1091
|
+
|
|
1092
|
+
# Add FIELDS keyword and field count
|
|
1093
|
+
args.extend(["FIELDS", str(len(field_value_map))])
|
|
1094
|
+
|
|
1095
|
+
# Add field-value pairs
|
|
1096
|
+
for field, value in field_value_map.items():
|
|
1097
|
+
args.extend([field, value])
|
|
1098
|
+
|
|
1099
|
+
return self.append_command(RequestType.HSetEx, args)
|
|
1100
|
+
|
|
1101
|
+
def hgetex(
|
|
1102
|
+
self: TBatch,
|
|
1103
|
+
key: TEncodable,
|
|
1104
|
+
fields: List[TEncodable],
|
|
1105
|
+
expiry: Optional[ExpiryGetEx] = None,
|
|
1106
|
+
) -> TBatch:
|
|
1107
|
+
"""
|
|
1108
|
+
Retrieves the values of specified fields in the hash stored at `key` and optionally sets their expiration.
|
|
1109
|
+
|
|
1110
|
+
See [valkey.io](https://valkey.io/commands/hgetex/) for more details.
|
|
1111
|
+
|
|
1112
|
+
Args:
|
|
1113
|
+
key (TEncodable): The key of the hash.
|
|
1114
|
+
fields (List[TEncodable]): The list of fields to retrieve from the hash.
|
|
1115
|
+
expiry (Optional[ExpiryGetEx]): Expiration options for the retrieved fields:
|
|
1116
|
+
- EX: Expiration time in seconds.
|
|
1117
|
+
- PX: Expiration time in milliseconds.
|
|
1118
|
+
- EXAT: Absolute expiration time in seconds (Unix timestamp).
|
|
1119
|
+
- PXAT: Absolute expiration time in milliseconds (Unix timestamp).
|
|
1120
|
+
- PERSIST: Remove expiration from the fields.
|
|
1121
|
+
|
|
1122
|
+
Commands response:
|
|
1123
|
+
Optional[List[Optional[bytes]]]: A list of values associated with the given fields, in the same order as requested.
|
|
1124
|
+
For every field that does not exist in the hash, a null value is returned.
|
|
1125
|
+
If `key` does not exist, it is treated as an empty hash, and the function returns a list of null values.
|
|
1126
|
+
|
|
1127
|
+
Since: Valkey 9.0.0
|
|
1128
|
+
"""
|
|
1129
|
+
args: List[TEncodable] = [key]
|
|
1130
|
+
|
|
1131
|
+
# Add expiry options if specified
|
|
1132
|
+
if expiry is not None:
|
|
1133
|
+
args.extend(expiry.get_cmd_args())
|
|
1134
|
+
|
|
1135
|
+
# Add FIELDS keyword and field count
|
|
1136
|
+
args.extend(["FIELDS", str(len(fields))])
|
|
1137
|
+
|
|
1138
|
+
# Add fields
|
|
1139
|
+
args.extend(fields)
|
|
1140
|
+
|
|
1141
|
+
return self.append_command(RequestType.HGetEx, args)
|
|
1142
|
+
|
|
1143
|
+
def hexpire(
|
|
1144
|
+
self: TBatch,
|
|
1145
|
+
key: TEncodable,
|
|
1146
|
+
seconds: int,
|
|
1147
|
+
fields: List[TEncodable],
|
|
1148
|
+
option: Optional[ExpireOptions] = None,
|
|
1149
|
+
) -> TBatch:
|
|
1150
|
+
"""
|
|
1151
|
+
Sets expiration time in seconds for one or more hash fields.
|
|
1152
|
+
|
|
1153
|
+
See [valkey.io](https://valkey.io/commands/hexpire/) for more details.
|
|
1154
|
+
|
|
1155
|
+
Args:
|
|
1156
|
+
key (TEncodable): The key of the hash.
|
|
1157
|
+
seconds (int): The expiration time in seconds.
|
|
1158
|
+
fields (List[TEncodable]): The list of fields to set expiration for.
|
|
1159
|
+
option (Optional[ExpireOptions]): Conditional expiration option:
|
|
1160
|
+
- HasNoExpiry (NX): Set expiration only when the field has no expiry.
|
|
1161
|
+
- HasExistingExpiry (XX): Set expiration only when the field has an existing expiry.
|
|
1162
|
+
- NewExpiryGreaterThanCurrent (GT): Set expiration only when the new expiry is greater than the current one.
|
|
1163
|
+
- NewExpiryLessThanCurrent (LT): Set expiration only when the new expiry is less than the current one.
|
|
1164
|
+
|
|
1165
|
+
Commands response:
|
|
1166
|
+
List[int]: A list of status codes for each field:
|
|
1167
|
+
- `1`: Expiration time was applied successfully.
|
|
1168
|
+
- `0`: Specified condition was not met.
|
|
1169
|
+
- `-2`: Field does not exist or key does not exist.
|
|
1170
|
+
- `2`: Field was deleted immediately (when seconds is 0 or timestamp is in the past).
|
|
1171
|
+
|
|
1172
|
+
Since: Valkey 9.0.0
|
|
1173
|
+
"""
|
|
1174
|
+
args: List[TEncodable] = [key, str(seconds)]
|
|
1175
|
+
|
|
1176
|
+
# Add conditional option if specified
|
|
1177
|
+
if option is not None:
|
|
1178
|
+
args.append(option.value)
|
|
1179
|
+
|
|
1180
|
+
# Add FIELDS keyword and field count
|
|
1181
|
+
args.extend(["FIELDS", str(len(fields))])
|
|
1182
|
+
|
|
1183
|
+
# Add fields
|
|
1184
|
+
args.extend(fields)
|
|
1185
|
+
|
|
1186
|
+
return self.append_command(RequestType.HExpire, args)
|
|
1187
|
+
|
|
1188
|
+
def hpersist(self: TBatch, key: TEncodable, fields: List[TEncodable]) -> TBatch:
|
|
1189
|
+
"""
|
|
1190
|
+
Removes the expiration from one or more hash fields, making them persistent.
|
|
1191
|
+
|
|
1192
|
+
See [valkey.io](https://valkey.io/commands/hpersist/) for more details.
|
|
1193
|
+
|
|
1194
|
+
Args:
|
|
1195
|
+
key (TEncodable): The key of the hash.
|
|
1196
|
+
fields (List[TEncodable]): The list of fields to remove expiration from.
|
|
1197
|
+
|
|
1198
|
+
Commands response:
|
|
1199
|
+
List[int]: A list of status codes for each field:
|
|
1200
|
+
- `1`: Expiration was removed successfully (field became persistent).
|
|
1201
|
+
- `-1`: Field exists but has no expiration.
|
|
1202
|
+
- `-2`: Field does not exist or key does not exist.
|
|
1203
|
+
|
|
1204
|
+
Since: Valkey 9.0.0
|
|
1205
|
+
"""
|
|
1206
|
+
args: List[TEncodable] = [key, "FIELDS", str(len(fields))] + fields
|
|
1207
|
+
|
|
1208
|
+
return self.append_command(RequestType.HPersist, args)
|
|
1209
|
+
|
|
1210
|
+
def hpexpire(
|
|
1211
|
+
self: TBatch,
|
|
1212
|
+
key: TEncodable,
|
|
1213
|
+
milliseconds: int,
|
|
1214
|
+
fields: List[TEncodable],
|
|
1215
|
+
option: Optional[ExpireOptions] = None,
|
|
1216
|
+
) -> TBatch:
|
|
1217
|
+
"""
|
|
1218
|
+
Sets expiration time in milliseconds for one or more hash fields.
|
|
1219
|
+
|
|
1220
|
+
See [valkey.io](https://valkey.io/commands/hpexpire/) for more details.
|
|
1221
|
+
|
|
1222
|
+
Args:
|
|
1223
|
+
key (TEncodable): The key of the hash.
|
|
1224
|
+
milliseconds (int): The expiration time in milliseconds.
|
|
1225
|
+
fields (List[TEncodable]): The list of fields to set expiration for.
|
|
1226
|
+
option (Optional[ExpireOptions]): Conditional expiration option:
|
|
1227
|
+
- HasNoExpiry (NX): Set expiration only when the field has no expiry.
|
|
1228
|
+
- HasExistingExpiry (XX): Set expiration only when the field has an existing expiry.
|
|
1229
|
+
- NewExpiryGreaterThanCurrent (GT): Set expiration only when the new expiry is greater than the current one.
|
|
1230
|
+
- NewExpiryLessThanCurrent (LT): Set expiration only when the new expiry is less than the current one.
|
|
1231
|
+
|
|
1232
|
+
Commands response:
|
|
1233
|
+
List[int]: A list of status codes for each field:
|
|
1234
|
+
- `1`: Expiration time was applied successfully.
|
|
1235
|
+
- `0`: Specified condition was not met.
|
|
1236
|
+
- `-2`: Field does not exist or key does not exist.
|
|
1237
|
+
- `2`: Field was deleted immediately (when milliseconds is 0 or timestamp is in the past).
|
|
1238
|
+
|
|
1239
|
+
Since: Valkey 9.0.0
|
|
1240
|
+
"""
|
|
1241
|
+
args: List[TEncodable] = [key, str(milliseconds)]
|
|
1242
|
+
|
|
1243
|
+
# Add conditional option if specified
|
|
1244
|
+
if option is not None:
|
|
1245
|
+
args.append(option.value)
|
|
1246
|
+
|
|
1247
|
+
# Add FIELDS keyword and field count
|
|
1248
|
+
args.extend(["FIELDS", str(len(fields))])
|
|
1249
|
+
|
|
1250
|
+
# Add fields
|
|
1251
|
+
args.extend(fields)
|
|
1252
|
+
|
|
1253
|
+
return self.append_command(RequestType.HPExpire, args)
|
|
1254
|
+
|
|
1255
|
+
def hexpireat(
|
|
1256
|
+
self: TBatch,
|
|
1257
|
+
key: TEncodable,
|
|
1258
|
+
unix_timestamp: int,
|
|
1259
|
+
fields: List[TEncodable],
|
|
1260
|
+
option: Optional[ExpireOptions] = None,
|
|
1261
|
+
) -> TBatch:
|
|
1262
|
+
"""
|
|
1263
|
+
Sets expiration time at absolute Unix timestamp in seconds for one or more hash fields.
|
|
1264
|
+
|
|
1265
|
+
See [valkey.io](https://valkey.io/commands/hexpireat/) for more details.
|
|
1266
|
+
|
|
1267
|
+
Args:
|
|
1268
|
+
key (TEncodable): The key of the hash.
|
|
1269
|
+
unix_timestamp (int): The absolute expiration time as Unix timestamp in seconds.
|
|
1270
|
+
fields (List[TEncodable]): The list of fields to set expiration for.
|
|
1271
|
+
option (Optional[ExpireOptions]): Conditional expiration option:
|
|
1272
|
+
- HasNoExpiry (NX): Set expiration only when the field has no expiry.
|
|
1273
|
+
- HasExistingExpiry (XX): Set expiration only when the field has an existing expiry.
|
|
1274
|
+
- NewExpiryGreaterThanCurrent (GT): Set expiration only when the new expiry is greater than the current one.
|
|
1275
|
+
- NewExpiryLessThanCurrent (LT): Set expiration only when the new expiry is less than the current one.
|
|
1276
|
+
|
|
1277
|
+
Commands response:
|
|
1278
|
+
List[int]: A list of status codes for each field:
|
|
1279
|
+
- `1`: Expiration time was applied successfully.
|
|
1280
|
+
- `0`: Specified condition was not met.
|
|
1281
|
+
- `-2`: Field does not exist or key does not exist.
|
|
1282
|
+
- `2`: Field was deleted immediately (when timestamp is in the past).
|
|
1283
|
+
|
|
1284
|
+
Since: Valkey 9.0.0
|
|
1285
|
+
"""
|
|
1286
|
+
args: List[TEncodable] = [key, str(unix_timestamp)]
|
|
1287
|
+
|
|
1288
|
+
# Add conditional option if specified
|
|
1289
|
+
if option is not None:
|
|
1290
|
+
args.append(option.value)
|
|
1291
|
+
|
|
1292
|
+
# Add FIELDS keyword and field count
|
|
1293
|
+
args.extend(["FIELDS", str(len(fields))])
|
|
1294
|
+
|
|
1295
|
+
# Add fields
|
|
1296
|
+
args.extend(fields)
|
|
1297
|
+
|
|
1298
|
+
return self.append_command(RequestType.HExpireAt, args)
|
|
1299
|
+
|
|
1300
|
+
def hpexpireat(
|
|
1301
|
+
self: TBatch,
|
|
1302
|
+
key: TEncodable,
|
|
1303
|
+
unix_timestamp_ms: int,
|
|
1304
|
+
fields: List[TEncodable],
|
|
1305
|
+
option: Optional[ExpireOptions] = None,
|
|
1306
|
+
) -> TBatch:
|
|
1307
|
+
"""
|
|
1308
|
+
Sets expiration time at absolute Unix timestamp in milliseconds for one or more hash fields.
|
|
1309
|
+
|
|
1310
|
+
See [valkey.io](https://valkey.io/commands/hpexpireat/) for more details.
|
|
1311
|
+
|
|
1312
|
+
Args:
|
|
1313
|
+
key (TEncodable): The key of the hash.
|
|
1314
|
+
unix_timestamp_ms (int): The absolute expiration time as Unix timestamp in milliseconds.
|
|
1315
|
+
fields (List[TEncodable]): The list of fields to set expiration for.
|
|
1316
|
+
option (Optional[ExpireOptions]): Conditional expiration option:
|
|
1317
|
+
- HasNoExpiry (NX): Set expiration only when the field has no expiry.
|
|
1318
|
+
- HasExistingExpiry (XX): Set expiration only when the field has an existing expiry.
|
|
1319
|
+
- NewExpiryGreaterThanCurrent (GT): Set expiration only when the new expiry is greater than the current one.
|
|
1320
|
+
- NewExpiryLessThanCurrent (LT): Set expiration only when the new expiry is less than the current one.
|
|
1321
|
+
|
|
1322
|
+
Commands response:
|
|
1323
|
+
List[int]: A list of status codes for each field:
|
|
1324
|
+
- `1`: Expiration time was applied successfully.
|
|
1325
|
+
- `0`: Specified condition was not met.
|
|
1326
|
+
- `-2`: Field does not exist or key does not exist.
|
|
1327
|
+
- `2`: Field was deleted immediately (when timestamp is in the past).
|
|
1328
|
+
|
|
1329
|
+
Since: Valkey 9.0.0
|
|
1330
|
+
"""
|
|
1331
|
+
args: List[TEncodable] = [key, str(unix_timestamp_ms)]
|
|
1332
|
+
|
|
1333
|
+
# Add conditional option if specified
|
|
1334
|
+
if option is not None:
|
|
1335
|
+
args.append(option.value)
|
|
1336
|
+
|
|
1337
|
+
# Add FIELDS keyword and field count
|
|
1338
|
+
args.extend(["FIELDS", str(len(fields))])
|
|
1339
|
+
|
|
1340
|
+
# Add fields
|
|
1341
|
+
args.extend(fields)
|
|
1342
|
+
|
|
1343
|
+
return self.append_command(RequestType.HPExpireAt, args)
|
|
1344
|
+
|
|
958
1345
|
def lpush(self: TBatch, key: TEncodable, elements: List[TEncodable]) -> TBatch:
|
|
959
1346
|
"""
|
|
960
1347
|
Insert all the specified values at the head of the list stored at `key`.
|
|
@@ -1694,8 +2081,8 @@ class BaseBatch:
|
|
|
1694
2081
|
Commands response:
|
|
1695
2082
|
TOK: A simple "OK" response.
|
|
1696
2083
|
|
|
1697
|
-
If `start` exceeds the end of the list, or if `start` is greater than `end`, the
|
|
1698
|
-
|
|
2084
|
+
If `start` exceeds the end of the list, or if `start` is greater than `end`, the list is emptied
|
|
2085
|
+
and the key is removed.
|
|
1699
2086
|
|
|
1700
2087
|
If `end` exceeds the actual end of the list, it will be treated like the last element of the list.
|
|
1701
2088
|
|
|
@@ -1711,16 +2098,18 @@ class BaseBatch:
|
|
|
1711
2098
|
) -> TBatch:
|
|
1712
2099
|
"""
|
|
1713
2100
|
Removes the first `count` occurrences of elements equal to `element` from the list stored at `key`.
|
|
1714
|
-
If `count` is positive, it removes elements equal to `element` moving from head to tail.
|
|
1715
|
-
If `count` is negative, it removes elements equal to `element` moving from tail to head.
|
|
1716
|
-
If `count` is 0 or greater than the occurrences of elements equal to `element`, it removes all elements
|
|
1717
|
-
equal to `element`.
|
|
1718
2101
|
|
|
1719
2102
|
See [valkey.io](https://valkey.io/commands/lrem/) for more details.
|
|
1720
2103
|
|
|
1721
2104
|
Args:
|
|
1722
2105
|
key (TEncodable): The key of the list.
|
|
1723
2106
|
count (int): The count of occurrences of elements equal to `element` to remove.
|
|
2107
|
+
|
|
2108
|
+
- If `count` is positive, it removes elements equal to `element` moving from head to tail.
|
|
2109
|
+
- If `count` is negative, it removes elements equal to `element` moving from tail to head.
|
|
2110
|
+
- If `count` is 0 or greater than the occurrences of elements equal to `element`, it removes all elements
|
|
2111
|
+
equal to `element`.
|
|
2112
|
+
|
|
1724
2113
|
element (TEncodable): The element to remove from the list.
|
|
1725
2114
|
|
|
1726
2115
|
Commands response:
|
|
@@ -2317,6 +2706,10 @@ class BaseBatch:
|
|
|
2317
2706
|
args.append("REPLACE")
|
|
2318
2707
|
if absttl is True:
|
|
2319
2708
|
args.append("ABSTTL")
|
|
2709
|
+
if idletime is not None and frequency is not None:
|
|
2710
|
+
raise RequestError(
|
|
2711
|
+
"syntax error: IDLETIME and FREQ cannot be set at the same time."
|
|
2712
|
+
)
|
|
2320
2713
|
if idletime is not None:
|
|
2321
2714
|
args.extend(["IDLETIME", str(idletime)])
|
|
2322
2715
|
if frequency is not None:
|
|
@@ -4275,10 +4668,10 @@ class BaseBatch:
|
|
|
4275
4668
|
elements (List[TEncodable]): A list of members to add to the HyperLogLog stored at `key`.
|
|
4276
4669
|
|
|
4277
4670
|
Commands response:
|
|
4278
|
-
|
|
4279
|
-
altered, then returns
|
|
4671
|
+
bool: If the HyperLogLog is newly created, or if the HyperLogLog approximated cardinality is
|
|
4672
|
+
altered, then returns `True`.
|
|
4280
4673
|
|
|
4281
|
-
Otherwise, returns
|
|
4674
|
+
Otherwise, returns `False`.
|
|
4282
4675
|
"""
|
|
4283
4676
|
return self.append_command(RequestType.PfAdd, [key] + elements)
|
|
4284
4677
|
|