coredis 4.23.1__py3-none-any.whl → 5.0.0rc1__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.
- coredis/__init__.py +1 -3
- coredis/_packer.py +10 -10
- coredis/_protocols.py +23 -32
- coredis/_py_311_typing.py +20 -0
- coredis/_py_312_typing.py +17 -0
- coredis/_utils.py +49 -51
- coredis/_version.py +3 -3
- coredis/cache.py +57 -82
- coredis/client/__init__.py +1 -2
- coredis/client/basic.py +129 -56
- coredis/client/cluster.py +147 -70
- coredis/commands/__init__.py +27 -7
- coredis/commands/_key_spec.py +11 -10
- coredis/commands/_utils.py +1 -1
- coredis/commands/_validators.py +30 -20
- coredis/commands/_wrappers.py +19 -99
- coredis/commands/bitfield.py +10 -2
- coredis/commands/constants.py +20 -3
- coredis/commands/core.py +1627 -1246
- coredis/commands/function.py +29 -22
- coredis/commands/monitor.py +0 -71
- coredis/commands/pubsub.py +7 -142
- coredis/commands/request.py +108 -0
- coredis/commands/script.py +9 -9
- coredis/commands/sentinel.py +60 -49
- coredis/connection.py +14 -15
- coredis/exceptions.py +2 -2
- coredis/experimental/__init__.py +0 -4
- coredis/globals.py +3 -0
- coredis/modules/autocomplete.py +28 -30
- coredis/modules/base.py +15 -31
- coredis/modules/filters.py +269 -245
- coredis/modules/graph.py +61 -62
- coredis/modules/json.py +172 -140
- coredis/modules/response/_callbacks/autocomplete.py +5 -4
- coredis/modules/response/_callbacks/graph.py +34 -29
- coredis/modules/response/_callbacks/json.py +5 -3
- coredis/modules/response/_callbacks/search.py +49 -53
- coredis/modules/response/_callbacks/timeseries.py +18 -30
- coredis/modules/response/types.py +1 -5
- coredis/modules/search.py +186 -169
- coredis/modules/timeseries.py +184 -164
- coredis/parser.py +6 -19
- coredis/pipeline.py +391 -422
- coredis/pool/basic.py +7 -7
- coredis/pool/cluster.py +3 -3
- coredis/pool/nodemanager.py +10 -3
- coredis/response/_callbacks/__init__.py +76 -57
- coredis/response/_callbacks/acl.py +0 -3
- coredis/response/_callbacks/cluster.py +25 -16
- coredis/response/_callbacks/command.py +8 -6
- coredis/response/_callbacks/connection.py +4 -3
- coredis/response/_callbacks/geo.py +17 -13
- coredis/response/_callbacks/hash.py +13 -11
- coredis/response/_callbacks/keys.py +9 -5
- coredis/response/_callbacks/module.py +2 -3
- coredis/response/_callbacks/script.py +6 -8
- coredis/response/_callbacks/sentinel.py +21 -17
- coredis/response/_callbacks/server.py +36 -14
- coredis/response/_callbacks/sets.py +3 -4
- coredis/response/_callbacks/sorted_set.py +27 -24
- coredis/response/_callbacks/streams.py +22 -13
- coredis/response/_callbacks/strings.py +7 -6
- coredis/response/_callbacks/vector_sets.py +126 -0
- coredis/response/types.py +13 -4
- coredis/sentinel.py +1 -1
- coredis/stream.py +4 -3
- coredis/tokens.py +343 -16
- coredis/typing.py +432 -79
- {coredis-4.23.1.dist-info → coredis-5.0.0rc1.dist-info}/METADATA +4 -5
- coredis-5.0.0rc1.dist-info/RECORD +95 -0
- coredis/client/keydb.py +0 -336
- coredis/pipeline.pyi +0 -2103
- coredis-4.23.1.dist-info/RECORD +0 -93
- {coredis-4.23.1.dist-info → coredis-5.0.0rc1.dist-info}/WHEEL +0 -0
- {coredis-4.23.1.dist-info → coredis-5.0.0rc1.dist-info}/licenses/LICENSE +0 -0
- {coredis-4.23.1.dist-info → coredis-5.0.0rc1.dist-info}/top_level.txt +0 -0
coredis/modules/graph.py
CHANGED
|
@@ -5,6 +5,7 @@ from datetime import timedelta
|
|
|
5
5
|
from ..commands._utils import normalized_milliseconds
|
|
6
6
|
from ..commands._wrappers import ClusterCommandConfig
|
|
7
7
|
from ..commands.constants import CommandGroup, CommandName, NodeFlag
|
|
8
|
+
from ..commands.request import CommandRequest
|
|
8
9
|
from ..response._callbacks import (
|
|
9
10
|
ClusterEnsureConsistent,
|
|
10
11
|
ClusterMergeSets,
|
|
@@ -19,9 +20,9 @@ from ..typing import (
|
|
|
19
20
|
KeyT,
|
|
20
21
|
Literal,
|
|
21
22
|
Parameters,
|
|
23
|
+
RedisValueT,
|
|
22
24
|
ResponsePrimitive,
|
|
23
25
|
StringT,
|
|
24
|
-
ValueT,
|
|
25
26
|
)
|
|
26
27
|
from .base import Module, ModuleGroup, module_command
|
|
27
28
|
from .response._callbacks.graph import (
|
|
@@ -51,12 +52,12 @@ class Graph(ModuleGroup[AnyStr]):
|
|
|
51
52
|
version_introduced="1.0.0",
|
|
52
53
|
group=COMMAND_GROUP,
|
|
53
54
|
)
|
|
54
|
-
|
|
55
|
+
def query(
|
|
55
56
|
self,
|
|
56
57
|
graph: KeyT,
|
|
57
58
|
query: StringT,
|
|
58
59
|
timeout: int | timedelta | None = None,
|
|
59
|
-
) -> GraphQueryResult[AnyStr]:
|
|
60
|
+
) -> CommandRequest[GraphQueryResult[AnyStr]]:
|
|
60
61
|
"""
|
|
61
62
|
Executes the given query against a specified graph
|
|
62
63
|
|
|
@@ -65,17 +66,16 @@ class Graph(ModuleGroup[AnyStr]):
|
|
|
65
66
|
:param timeout: The maximum amount of time (milliseconds) to wait for the query to complete
|
|
66
67
|
:return: The result set of the executed query.
|
|
67
68
|
"""
|
|
68
|
-
|
|
69
|
+
command_arguments: CommandArgList = [graph, query]
|
|
69
70
|
|
|
70
71
|
if timeout is not None:
|
|
71
|
-
|
|
72
|
+
command_arguments.extend([PrefixToken.TIMEOUT, normalized_milliseconds(timeout)])
|
|
72
73
|
|
|
73
|
-
|
|
74
|
-
return
|
|
74
|
+
command_arguments.append(b"--compact")
|
|
75
|
+
return self.client.create_request(
|
|
75
76
|
CommandName.GRAPH_QUERY,
|
|
76
|
-
*
|
|
77
|
-
callback=QueryCallback[AnyStr](graph),
|
|
78
|
-
query=query,
|
|
77
|
+
*command_arguments,
|
|
78
|
+
callback=QueryCallback[AnyStr](graph, query=query),
|
|
79
79
|
)
|
|
80
80
|
|
|
81
81
|
@module_command(
|
|
@@ -84,12 +84,12 @@ class Graph(ModuleGroup[AnyStr]):
|
|
|
84
84
|
version_introduced="2.2.8",
|
|
85
85
|
group=COMMAND_GROUP,
|
|
86
86
|
)
|
|
87
|
-
|
|
87
|
+
def ro_query(
|
|
88
88
|
self,
|
|
89
89
|
graph: KeyT,
|
|
90
90
|
query: StringT,
|
|
91
91
|
timeout: int | timedelta | None = None,
|
|
92
|
-
) -> GraphQueryResult[AnyStr]:
|
|
92
|
+
) -> CommandRequest[GraphQueryResult[AnyStr]]:
|
|
93
93
|
"""
|
|
94
94
|
Executes a given read only query against a specified graph
|
|
95
95
|
|
|
@@ -98,16 +98,15 @@ class Graph(ModuleGroup[AnyStr]):
|
|
|
98
98
|
:param timeout: The maximum amount of time (milliseconds) to wait for the query to complete.
|
|
99
99
|
:return: The result set for the read-only query or an error if a write query was given.
|
|
100
100
|
"""
|
|
101
|
-
|
|
101
|
+
command_arguments: CommandArgList = [graph, query]
|
|
102
102
|
if timeout is not None:
|
|
103
|
-
|
|
104
|
-
|
|
103
|
+
command_arguments.extend([PrefixToken.TIMEOUT, normalized_milliseconds(timeout)])
|
|
104
|
+
command_arguments.append(b"--compact")
|
|
105
105
|
|
|
106
|
-
return
|
|
106
|
+
return self.client.create_request(
|
|
107
107
|
CommandName.GRAPH_RO_QUERY,
|
|
108
|
-
*
|
|
109
|
-
callback=QueryCallback[AnyStr](graph),
|
|
110
|
-
query=query,
|
|
108
|
+
*command_arguments,
|
|
109
|
+
callback=QueryCallback[AnyStr](graph, query=query),
|
|
111
110
|
)
|
|
112
111
|
|
|
113
112
|
@module_command(
|
|
@@ -116,7 +115,7 @@ class Graph(ModuleGroup[AnyStr]):
|
|
|
116
115
|
version_introduced="1.0.0",
|
|
117
116
|
group=COMMAND_GROUP,
|
|
118
117
|
)
|
|
119
|
-
|
|
118
|
+
def delete(self, graph: KeyT) -> CommandRequest[bool]:
|
|
120
119
|
"""
|
|
121
120
|
Completely removes the graph and all of its entities
|
|
122
121
|
|
|
@@ -125,7 +124,7 @@ class Graph(ModuleGroup[AnyStr]):
|
|
|
125
124
|
:param graph: The name of the graph to be deleted.
|
|
126
125
|
"""
|
|
127
126
|
|
|
128
|
-
return
|
|
127
|
+
return self.client.create_request(
|
|
129
128
|
CommandName.GRAPH_DELETE,
|
|
130
129
|
graph,
|
|
131
130
|
callback=SimpleStringCallback(prefix_match=True, ok_values={"Graph removed"}),
|
|
@@ -137,7 +136,7 @@ class Graph(ModuleGroup[AnyStr]):
|
|
|
137
136
|
version_introduced="2.0.0",
|
|
138
137
|
group=COMMAND_GROUP,
|
|
139
138
|
)
|
|
140
|
-
|
|
139
|
+
def explain(self, graph: KeyT, query: StringT) -> CommandRequest[list[AnyStr]]:
|
|
141
140
|
"""
|
|
142
141
|
|
|
143
142
|
Constructs a query execution plan for the given :paramref:`graph` and
|
|
@@ -149,7 +148,7 @@ class Graph(ModuleGroup[AnyStr]):
|
|
|
149
148
|
:return: A list of strings representing the query execution plan.
|
|
150
149
|
"""
|
|
151
150
|
|
|
152
|
-
return
|
|
151
|
+
return self.client.create_request(
|
|
153
152
|
CommandName.GRAPH_EXPLAIN, graph, query, callback=ListCallback[AnyStr]()
|
|
154
153
|
)
|
|
155
154
|
|
|
@@ -159,12 +158,12 @@ class Graph(ModuleGroup[AnyStr]):
|
|
|
159
158
|
version_introduced="2.0.0",
|
|
160
159
|
group=COMMAND_GROUP,
|
|
161
160
|
)
|
|
162
|
-
|
|
161
|
+
def profile(
|
|
163
162
|
self,
|
|
164
163
|
graph: KeyT,
|
|
165
164
|
query: StringT,
|
|
166
165
|
timeout: int | timedelta | None = None,
|
|
167
|
-
) -> list[AnyStr]:
|
|
166
|
+
) -> CommandRequest[list[AnyStr]]:
|
|
168
167
|
"""
|
|
169
168
|
Executes a query and returns an execution plan augmented with metrics for each
|
|
170
169
|
operation's execution
|
|
@@ -175,11 +174,13 @@ class Graph(ModuleGroup[AnyStr]):
|
|
|
175
174
|
:return: A string representation of a query execution plan, with details on results produced
|
|
176
175
|
by and time spent in each operation.
|
|
177
176
|
"""
|
|
178
|
-
|
|
177
|
+
command_arguments: CommandArgList = [graph, query]
|
|
179
178
|
if timeout is not None:
|
|
180
|
-
|
|
181
|
-
return
|
|
182
|
-
CommandName.GRAPH_PROFILE,
|
|
179
|
+
command_arguments.extend([PrefixToken.TIMEOUT, normalized_milliseconds(timeout)])
|
|
180
|
+
return self.client.create_request(
|
|
181
|
+
CommandName.GRAPH_PROFILE,
|
|
182
|
+
*command_arguments,
|
|
183
|
+
callback=ListCallback[AnyStr](),
|
|
183
184
|
)
|
|
184
185
|
|
|
185
186
|
@module_command(
|
|
@@ -189,9 +190,9 @@ class Graph(ModuleGroup[AnyStr]):
|
|
|
189
190
|
arguments={"reset": {"version_introduced": "2.12.0"}},
|
|
190
191
|
group=COMMAND_GROUP,
|
|
191
192
|
)
|
|
192
|
-
|
|
193
|
+
def slowlog(
|
|
193
194
|
self, graph: KeyT, reset: bool = False
|
|
194
|
-
) -> tuple[GraphSlowLogInfo, ...] | bool:
|
|
195
|
+
) -> CommandRequest[tuple[GraphSlowLogInfo, ...]] | CommandRequest[bool]:
|
|
195
196
|
"""
|
|
196
197
|
Returns a list containing up to 10 of the slowest queries issued against the given graph
|
|
197
198
|
|
|
@@ -199,18 +200,18 @@ class Graph(ModuleGroup[AnyStr]):
|
|
|
199
200
|
:param reset: If ``True``, the slowlog will be reset
|
|
200
201
|
:return: The slowlog for the given graph or ``True`` if the slowlog was reset
|
|
201
202
|
"""
|
|
202
|
-
|
|
203
|
+
command_arguments: CommandArgList = [graph]
|
|
203
204
|
if reset:
|
|
204
|
-
|
|
205
|
-
return
|
|
205
|
+
command_arguments.append(PureToken.RESET)
|
|
206
|
+
return self.client.create_request(
|
|
206
207
|
CommandName.GRAPH_SLOWLOG,
|
|
207
|
-
*
|
|
208
|
+
*command_arguments,
|
|
208
209
|
callback=SimpleStringCallback(),
|
|
209
210
|
)
|
|
210
211
|
else:
|
|
211
|
-
return
|
|
212
|
+
return self.client.create_request(
|
|
212
213
|
CommandName.GRAPH_SLOWLOG,
|
|
213
|
-
*
|
|
214
|
+
*command_arguments,
|
|
214
215
|
callback=GraphSlowLogCallback(),
|
|
215
216
|
)
|
|
216
217
|
|
|
@@ -223,9 +224,9 @@ class Graph(ModuleGroup[AnyStr]):
|
|
|
223
224
|
route=NodeFlag.RANDOM,
|
|
224
225
|
),
|
|
225
226
|
)
|
|
226
|
-
|
|
227
|
+
def config_get(
|
|
227
228
|
self, name: StringT
|
|
228
|
-
) -> dict[AnyStr, ResponsePrimitive] | ResponsePrimitive:
|
|
229
|
+
) -> CommandRequest[dict[AnyStr, ResponsePrimitive] | ResponsePrimitive]:
|
|
229
230
|
"""
|
|
230
231
|
Retrieves a RedisGraph configuration
|
|
231
232
|
|
|
@@ -233,7 +234,7 @@ class Graph(ModuleGroup[AnyStr]):
|
|
|
233
234
|
:return: The value of the configuration parameter. If :paramref:`name`
|
|
234
235
|
is ``*``, a mapping of all configuration parameters to their values
|
|
235
236
|
"""
|
|
236
|
-
return
|
|
237
|
+
return self.client.create_request(
|
|
237
238
|
CommandName.GRAPH_CONFIG_GET,
|
|
238
239
|
name,
|
|
239
240
|
callback=ConfigGetCallback[AnyStr](),
|
|
@@ -249,7 +250,7 @@ class Graph(ModuleGroup[AnyStr]):
|
|
|
249
250
|
combine=ClusterEnsureConsistent[AnyStr](),
|
|
250
251
|
),
|
|
251
252
|
)
|
|
252
|
-
|
|
253
|
+
def config_set(self, name: StringT, value: RedisValueT) -> CommandRequest[bool]:
|
|
253
254
|
"""
|
|
254
255
|
Updates a RedisGraph configuration
|
|
255
256
|
|
|
@@ -257,7 +258,7 @@ class Graph(ModuleGroup[AnyStr]):
|
|
|
257
258
|
:param value: The value to set the configuration parameter to.
|
|
258
259
|
:return: True if the configuration parameter was set successfully, False otherwise.
|
|
259
260
|
"""
|
|
260
|
-
return
|
|
261
|
+
return self.client.create_request(
|
|
261
262
|
CommandName.GRAPH_CONFIG_SET, name, value, callback=SimpleStringCallback()
|
|
262
263
|
)
|
|
263
264
|
|
|
@@ -271,16 +272,14 @@ class Graph(ModuleGroup[AnyStr]):
|
|
|
271
272
|
combine=ClusterMergeSets[AnyStr](),
|
|
272
273
|
),
|
|
273
274
|
)
|
|
274
|
-
|
|
275
|
+
def list(self) -> CommandRequest[set[AnyStr]]:
|
|
275
276
|
"""
|
|
276
277
|
Lists all graph keys in the keyspace
|
|
277
278
|
|
|
278
279
|
:return: A list of graph keys in the keyspace.
|
|
279
280
|
"""
|
|
280
281
|
|
|
281
|
-
return
|
|
282
|
-
CommandName.GRAPH_LIST, callback=SetCallback[AnyStr]()
|
|
283
|
-
)
|
|
282
|
+
return self.client.create_request(CommandName.GRAPH_LIST, callback=SetCallback[AnyStr]())
|
|
284
283
|
|
|
285
284
|
@module_command(
|
|
286
285
|
CommandName.GRAPH_CONSTRAINT_DROP,
|
|
@@ -288,14 +287,14 @@ class Graph(ModuleGroup[AnyStr]):
|
|
|
288
287
|
version_introduced="2.12.0",
|
|
289
288
|
group=COMMAND_GROUP,
|
|
290
289
|
)
|
|
291
|
-
|
|
290
|
+
def constraint_drop(
|
|
292
291
|
self,
|
|
293
292
|
graph: KeyT,
|
|
294
293
|
type: Literal[PureToken.MANDATORY, PureToken.UNIQUE],
|
|
295
294
|
node: StringT | None = None,
|
|
296
295
|
relationship: StringT | None = None,
|
|
297
296
|
properties: Parameters[StringT] | None = None,
|
|
298
|
-
) -> bool:
|
|
297
|
+
) -> CommandRequest[bool]:
|
|
299
298
|
"""
|
|
300
299
|
Deletes a constraint from specified graph
|
|
301
300
|
|
|
@@ -307,18 +306,18 @@ class Graph(ModuleGroup[AnyStr]):
|
|
|
307
306
|
|
|
308
307
|
:return: True if the constraint was successfully dropped, False otherwise.
|
|
309
308
|
"""
|
|
310
|
-
|
|
309
|
+
command_arguments: CommandArgList = [graph, type]
|
|
311
310
|
if node is not None:
|
|
312
|
-
|
|
311
|
+
command_arguments.extend([PrefixToken.NODE, node])
|
|
313
312
|
if relationship is not None:
|
|
314
|
-
|
|
313
|
+
command_arguments.extend([PrefixToken.RELATIONSHIP, relationship])
|
|
315
314
|
if properties:
|
|
316
315
|
_props: list[StringT] = list(properties)
|
|
317
|
-
|
|
316
|
+
command_arguments.extend([PrefixToken.PROPERTIES, len(_props), *_props])
|
|
318
317
|
|
|
319
|
-
return
|
|
318
|
+
return self.client.create_request(
|
|
320
319
|
CommandName.GRAPH_CONSTRAINT_DROP,
|
|
321
|
-
*
|
|
320
|
+
*command_arguments,
|
|
322
321
|
callback=SimpleStringCallback(),
|
|
323
322
|
)
|
|
324
323
|
|
|
@@ -328,14 +327,14 @@ class Graph(ModuleGroup[AnyStr]):
|
|
|
328
327
|
version_introduced="2.12.0",
|
|
329
328
|
group=COMMAND_GROUP,
|
|
330
329
|
)
|
|
331
|
-
|
|
330
|
+
def constraint_create(
|
|
332
331
|
self,
|
|
333
332
|
graph: KeyT,
|
|
334
333
|
type: Literal[PureToken.MANDATORY, PureToken.UNIQUE],
|
|
335
334
|
node: StringT | None = None,
|
|
336
335
|
relationship: StringT | None = None,
|
|
337
336
|
properties: Parameters[StringT] | None = None,
|
|
338
|
-
) -> bool:
|
|
337
|
+
) -> CommandRequest[bool]:
|
|
339
338
|
"""
|
|
340
339
|
Creates a constraint on specified graph
|
|
341
340
|
|
|
@@ -347,17 +346,17 @@ class Graph(ModuleGroup[AnyStr]):
|
|
|
347
346
|
:param properties: The properties to apply the constraint to.
|
|
348
347
|
:return: True if the constraint was created successfully, False otherwise.
|
|
349
348
|
"""
|
|
350
|
-
|
|
349
|
+
command_arguments: CommandArgList = [graph, type]
|
|
351
350
|
|
|
352
351
|
if node is not None:
|
|
353
|
-
|
|
352
|
+
command_arguments.extend([PrefixToken.NODE, node])
|
|
354
353
|
if relationship is not None:
|
|
355
|
-
|
|
354
|
+
command_arguments.extend([PrefixToken.RELATIONSHIP, relationship])
|
|
356
355
|
if properties:
|
|
357
356
|
_props: list[StringT] = list(properties)
|
|
358
|
-
|
|
359
|
-
return
|
|
357
|
+
command_arguments.extend([PrefixToken.PROPERTIES, len(_props), *_props])
|
|
358
|
+
return self.client.create_request(
|
|
360
359
|
CommandName.GRAPH_CONSTRAINT_CREATE,
|
|
361
|
-
*
|
|
360
|
+
*command_arguments,
|
|
362
361
|
callback=SimpleStringCallback(ok_values={"PENDING"}),
|
|
363
362
|
)
|