coredis 5.5.0__cp313-cp313-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.
Files changed (100) hide show
  1. 22fe76227e35f92ab5c3__mypyc.cpython-313-darwin.so +0 -0
  2. coredis/__init__.py +42 -0
  3. coredis/_enum.py +42 -0
  4. coredis/_json.py +11 -0
  5. coredis/_packer.cpython-313-darwin.so +0 -0
  6. coredis/_packer.py +71 -0
  7. coredis/_protocols.py +50 -0
  8. coredis/_py_311_typing.py +20 -0
  9. coredis/_py_312_typing.py +17 -0
  10. coredis/_sidecar.py +114 -0
  11. coredis/_utils.cpython-313-darwin.so +0 -0
  12. coredis/_utils.py +440 -0
  13. coredis/_version.py +34 -0
  14. coredis/_version.pyi +1 -0
  15. coredis/cache.py +801 -0
  16. coredis/client/__init__.py +6 -0
  17. coredis/client/basic.py +1240 -0
  18. coredis/client/cluster.py +1265 -0
  19. coredis/commands/__init__.py +64 -0
  20. coredis/commands/_key_spec.py +517 -0
  21. coredis/commands/_utils.py +108 -0
  22. coredis/commands/_validators.py +159 -0
  23. coredis/commands/_wrappers.py +175 -0
  24. coredis/commands/bitfield.py +110 -0
  25. coredis/commands/constants.py +662 -0
  26. coredis/commands/core.py +8484 -0
  27. coredis/commands/function.py +408 -0
  28. coredis/commands/monitor.py +168 -0
  29. coredis/commands/pubsub.py +905 -0
  30. coredis/commands/request.py +108 -0
  31. coredis/commands/script.py +296 -0
  32. coredis/commands/sentinel.py +246 -0
  33. coredis/config.py +50 -0
  34. coredis/connection.py +906 -0
  35. coredis/constants.cpython-313-darwin.so +0 -0
  36. coredis/constants.py +37 -0
  37. coredis/credentials.py +45 -0
  38. coredis/exceptions.py +360 -0
  39. coredis/experimental/__init__.py +1 -0
  40. coredis/globals.py +23 -0
  41. coredis/modules/__init__.py +121 -0
  42. coredis/modules/autocomplete.py +138 -0
  43. coredis/modules/base.py +262 -0
  44. coredis/modules/filters.py +1319 -0
  45. coredis/modules/graph.py +362 -0
  46. coredis/modules/json.py +691 -0
  47. coredis/modules/response/__init__.py +0 -0
  48. coredis/modules/response/_callbacks/__init__.py +0 -0
  49. coredis/modules/response/_callbacks/autocomplete.py +42 -0
  50. coredis/modules/response/_callbacks/graph.py +237 -0
  51. coredis/modules/response/_callbacks/json.py +21 -0
  52. coredis/modules/response/_callbacks/search.py +221 -0
  53. coredis/modules/response/_callbacks/timeseries.py +158 -0
  54. coredis/modules/response/types.py +179 -0
  55. coredis/modules/search.py +1089 -0
  56. coredis/modules/timeseries.py +1139 -0
  57. coredis/parser.cpython-313-darwin.so +0 -0
  58. coredis/parser.py +344 -0
  59. coredis/pipeline.py +1225 -0
  60. coredis/pool/__init__.py +11 -0
  61. coredis/pool/basic.py +453 -0
  62. coredis/pool/cluster.py +517 -0
  63. coredis/pool/nodemanager.py +340 -0
  64. coredis/py.typed +0 -0
  65. coredis/recipes/__init__.py +0 -0
  66. coredis/recipes/credentials/__init__.py +5 -0
  67. coredis/recipes/credentials/iam_provider.py +63 -0
  68. coredis/recipes/locks/__init__.py +5 -0
  69. coredis/recipes/locks/extend.lua +17 -0
  70. coredis/recipes/locks/lua_lock.py +281 -0
  71. coredis/recipes/locks/release.lua +10 -0
  72. coredis/response/__init__.py +5 -0
  73. coredis/response/_callbacks/__init__.py +538 -0
  74. coredis/response/_callbacks/acl.py +32 -0
  75. coredis/response/_callbacks/cluster.py +183 -0
  76. coredis/response/_callbacks/command.py +86 -0
  77. coredis/response/_callbacks/connection.py +31 -0
  78. coredis/response/_callbacks/geo.py +58 -0
  79. coredis/response/_callbacks/hash.py +85 -0
  80. coredis/response/_callbacks/keys.py +59 -0
  81. coredis/response/_callbacks/module.py +33 -0
  82. coredis/response/_callbacks/script.py +85 -0
  83. coredis/response/_callbacks/sentinel.py +179 -0
  84. coredis/response/_callbacks/server.py +241 -0
  85. coredis/response/_callbacks/sets.py +44 -0
  86. coredis/response/_callbacks/sorted_set.py +204 -0
  87. coredis/response/_callbacks/streams.py +185 -0
  88. coredis/response/_callbacks/strings.py +70 -0
  89. coredis/response/_callbacks/vector_sets.py +159 -0
  90. coredis/response/_utils.py +33 -0
  91. coredis/response/types.py +416 -0
  92. coredis/retry.py +233 -0
  93. coredis/sentinel.py +477 -0
  94. coredis/stream.py +369 -0
  95. coredis/tokens.py +2286 -0
  96. coredis/typing.py +593 -0
  97. coredis-5.5.0.dist-info/METADATA +211 -0
  98. coredis-5.5.0.dist-info/RECORD +100 -0
  99. coredis-5.5.0.dist-info/WHEEL +6 -0
  100. coredis-5.5.0.dist-info/licenses/LICENSE +23 -0
@@ -0,0 +1,362 @@
1
+ from __future__ import annotations
2
+
3
+ from datetime import timedelta
4
+
5
+ from ..commands._utils import normalized_milliseconds
6
+ from ..commands._wrappers import ClusterCommandConfig
7
+ from ..commands.constants import CommandGroup, CommandName, NodeFlag
8
+ from ..commands.request import CommandRequest
9
+ from ..response._callbacks import (
10
+ ClusterEnsureConsistent,
11
+ ClusterMergeSets,
12
+ ListCallback,
13
+ SetCallback,
14
+ SimpleStringCallback,
15
+ )
16
+ from ..tokens import PrefixToken, PureToken
17
+ from ..typing import (
18
+ AnyStr,
19
+ CommandArgList,
20
+ KeyT,
21
+ Literal,
22
+ Parameters,
23
+ RedisValueT,
24
+ ResponsePrimitive,
25
+ StringT,
26
+ )
27
+ from .base import Module, ModuleGroup, module_command
28
+ from .response._callbacks.graph import (
29
+ ConfigGetCallback,
30
+ GraphSlowLogCallback,
31
+ QueryCallback,
32
+ )
33
+ from .response.types import GraphQueryResult, GraphSlowLogInfo
34
+
35
+
36
+ class RedisGraph(Module[AnyStr]):
37
+ NAME = "graph"
38
+ FULL_NAME = "RedisGraph"
39
+ DESCRIPTION = """RedisGraph is a queryable Property Graph database that uses sparse matrices
40
+ to represent the adjacency matrix in graphs and linear algebra to query the graph.
41
+ """
42
+ DOCUMENTATION_URL = "https://redis.io/docs/stack/graph/"
43
+
44
+
45
+ class Graph(ModuleGroup[AnyStr]):
46
+ MODULE = RedisGraph
47
+ COMMAND_GROUP = CommandGroup.GRAPH
48
+
49
+ @module_command(
50
+ CommandName.GRAPH_QUERY,
51
+ module=MODULE,
52
+ version_introduced="1.0.0",
53
+ group=COMMAND_GROUP,
54
+ )
55
+ def query(
56
+ self,
57
+ graph: KeyT,
58
+ query: StringT,
59
+ timeout: int | timedelta | None = None,
60
+ ) -> CommandRequest[GraphQueryResult[AnyStr]]:
61
+ """
62
+ Executes the given query against a specified graph
63
+
64
+ :param graph: The name of the graph to query.
65
+ :param query: The query to execute.
66
+ :param timeout: The maximum amount of time (milliseconds) to wait for the query to complete
67
+ :return: The result set of the executed query.
68
+ """
69
+ command_arguments: CommandArgList = [graph, query]
70
+
71
+ if timeout is not None:
72
+ command_arguments.extend([PrefixToken.TIMEOUT, normalized_milliseconds(timeout)])
73
+
74
+ command_arguments.append(b"--compact")
75
+ return self.client.create_request(
76
+ CommandName.GRAPH_QUERY,
77
+ *command_arguments,
78
+ callback=QueryCallback[AnyStr](graph, query=query),
79
+ )
80
+
81
+ @module_command(
82
+ CommandName.GRAPH_RO_QUERY,
83
+ module=MODULE,
84
+ version_introduced="2.2.8",
85
+ group=COMMAND_GROUP,
86
+ )
87
+ def ro_query(
88
+ self,
89
+ graph: KeyT,
90
+ query: StringT,
91
+ timeout: int | timedelta | None = None,
92
+ ) -> CommandRequest[GraphQueryResult[AnyStr]]:
93
+ """
94
+ Executes a given read only query against a specified graph
95
+
96
+ :param graph: The name of the graph to query.
97
+ :param query: The query to execute.
98
+ :param timeout: The maximum amount of time (milliseconds) to wait for the query to complete.
99
+ :return: The result set for the read-only query or an error if a write query was given.
100
+ """
101
+ command_arguments: CommandArgList = [graph, query]
102
+ if timeout is not None:
103
+ command_arguments.extend([PrefixToken.TIMEOUT, normalized_milliseconds(timeout)])
104
+ command_arguments.append(b"--compact")
105
+
106
+ return self.client.create_request(
107
+ CommandName.GRAPH_RO_QUERY,
108
+ *command_arguments,
109
+ callback=QueryCallback[AnyStr](graph, query=query),
110
+ )
111
+
112
+ @module_command(
113
+ CommandName.GRAPH_DELETE,
114
+ module=MODULE,
115
+ version_introduced="1.0.0",
116
+ group=COMMAND_GROUP,
117
+ )
118
+ def delete(self, graph: KeyT) -> CommandRequest[bool]:
119
+ """
120
+ Completely removes the graph and all of its entities
121
+
122
+ Deletes the entire graph and all of its entities.
123
+
124
+ :param graph: The name of the graph to be deleted.
125
+ """
126
+
127
+ return self.client.create_request(
128
+ CommandName.GRAPH_DELETE,
129
+ graph,
130
+ callback=SimpleStringCallback(prefix_match=True, ok_values={"Graph removed"}),
131
+ )
132
+
133
+ @module_command(
134
+ CommandName.GRAPH_EXPLAIN,
135
+ module=MODULE,
136
+ version_introduced="2.0.0",
137
+ group=COMMAND_GROUP,
138
+ )
139
+ def explain(self, graph: KeyT, query: StringT) -> CommandRequest[list[AnyStr]]:
140
+ """
141
+
142
+ Constructs a query execution plan for the given :paramref:`graph` and
143
+ :paramref:`query`, but does not execute it.
144
+
145
+ :param graph: The name of the graph to execute the query on.
146
+ :param query: The query to construct the execution plan for.
147
+
148
+ :return: A list of strings representing the query execution plan.
149
+ """
150
+
151
+ return self.client.create_request(
152
+ CommandName.GRAPH_EXPLAIN, graph, query, callback=ListCallback[AnyStr]()
153
+ )
154
+
155
+ @module_command(
156
+ CommandName.GRAPH_PROFILE,
157
+ module=MODULE,
158
+ version_introduced="2.0.0",
159
+ group=COMMAND_GROUP,
160
+ )
161
+ def profile(
162
+ self,
163
+ graph: KeyT,
164
+ query: StringT,
165
+ timeout: int | timedelta | None = None,
166
+ ) -> CommandRequest[list[AnyStr]]:
167
+ """
168
+ Executes a query and returns an execution plan augmented with metrics for each
169
+ operation's execution
170
+
171
+ :param graph: The name of the graph to execute the query on.
172
+ :param query: The query to execute and return a profile for.
173
+ :param timeout: Optional timeout for the query execution in milliseconds.
174
+ :return: A string representation of a query execution plan, with details on results produced
175
+ by and time spent in each operation.
176
+ """
177
+ command_arguments: CommandArgList = [graph, query]
178
+ if timeout is not None:
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](),
184
+ )
185
+
186
+ @module_command(
187
+ CommandName.GRAPH_SLOWLOG,
188
+ module=MODULE,
189
+ version_introduced="2.0.12",
190
+ arguments={"reset": {"version_introduced": "2.12.0"}},
191
+ group=COMMAND_GROUP,
192
+ )
193
+ def slowlog(
194
+ self, graph: KeyT, reset: bool = False
195
+ ) -> CommandRequest[tuple[GraphSlowLogInfo, ...]] | CommandRequest[bool]:
196
+ """
197
+ Returns a list containing up to 10 of the slowest queries issued against the given graph
198
+
199
+ :param graph: The name of the graph
200
+ :param reset: If ``True``, the slowlog will be reset
201
+ :return: The slowlog for the given graph or ``True`` if the slowlog was reset
202
+ """
203
+ command_arguments: CommandArgList = [graph]
204
+ if reset:
205
+ command_arguments.append(PureToken.RESET)
206
+ return self.client.create_request(
207
+ CommandName.GRAPH_SLOWLOG,
208
+ *command_arguments,
209
+ callback=SimpleStringCallback(),
210
+ )
211
+ else:
212
+ return self.client.create_request(
213
+ CommandName.GRAPH_SLOWLOG,
214
+ *command_arguments,
215
+ callback=GraphSlowLogCallback(),
216
+ )
217
+
218
+ @module_command(
219
+ CommandName.GRAPH_CONFIG_GET,
220
+ module=MODULE,
221
+ version_introduced="2.2.11",
222
+ group=COMMAND_GROUP,
223
+ cluster=ClusterCommandConfig(
224
+ route=NodeFlag.RANDOM,
225
+ ),
226
+ )
227
+ def config_get(
228
+ self, name: StringT
229
+ ) -> CommandRequest[dict[AnyStr, ResponsePrimitive] | ResponsePrimitive]:
230
+ """
231
+ Retrieves a RedisGraph configuration
232
+
233
+ :param name: The name of the configuration parameter to retrieve.
234
+ :return: The value of the configuration parameter. If :paramref:`name`
235
+ is ``*``, a mapping of all configuration parameters to their values
236
+ """
237
+ return self.client.create_request(
238
+ CommandName.GRAPH_CONFIG_GET,
239
+ name,
240
+ callback=ConfigGetCallback[AnyStr](),
241
+ )
242
+
243
+ @module_command(
244
+ CommandName.GRAPH_CONFIG_SET,
245
+ module=MODULE,
246
+ version_introduced="2.2.11",
247
+ group=COMMAND_GROUP,
248
+ cluster=ClusterCommandConfig(
249
+ route=NodeFlag.PRIMARIES,
250
+ combine=ClusterEnsureConsistent[AnyStr](),
251
+ ),
252
+ )
253
+ def config_set(self, name: StringT, value: RedisValueT) -> CommandRequest[bool]:
254
+ """
255
+ Updates a RedisGraph configuration
256
+
257
+ :param name: The name of the configuration parameter to set.
258
+ :param value: The value to set the configuration parameter to.
259
+ :return: True if the configuration parameter was set successfully, False otherwise.
260
+ """
261
+ return self.client.create_request(
262
+ CommandName.GRAPH_CONFIG_SET, name, value, callback=SimpleStringCallback()
263
+ )
264
+
265
+ @module_command(
266
+ CommandName.GRAPH_LIST,
267
+ module=MODULE,
268
+ version_introduced="2.4.3",
269
+ group=COMMAND_GROUP,
270
+ cluster=ClusterCommandConfig(
271
+ route=NodeFlag.PRIMARIES,
272
+ combine=ClusterMergeSets[AnyStr](),
273
+ ),
274
+ )
275
+ def list(self) -> CommandRequest[set[AnyStr]]:
276
+ """
277
+ Lists all graph keys in the keyspace
278
+
279
+ :return: A list of graph keys in the keyspace.
280
+ """
281
+
282
+ return self.client.create_request(CommandName.GRAPH_LIST, callback=SetCallback[AnyStr]())
283
+
284
+ @module_command(
285
+ CommandName.GRAPH_CONSTRAINT_DROP,
286
+ module=MODULE,
287
+ version_introduced="2.12.0",
288
+ group=COMMAND_GROUP,
289
+ )
290
+ def constraint_drop(
291
+ self,
292
+ graph: KeyT,
293
+ type: Literal[PureToken.MANDATORY, PureToken.UNIQUE],
294
+ node: StringT | None = None,
295
+ relationship: StringT | None = None,
296
+ properties: Parameters[StringT] | None = None,
297
+ ) -> CommandRequest[bool]:
298
+ """
299
+ Deletes a constraint from specified graph
300
+
301
+ :param graph: The name of the RedisGraph.
302
+ :param type: The type of constraint to drop.
303
+ :param node: The name of the node to drop the constraint from
304
+ :param relationship: The name of the relationship to drop the constraint from
305
+ :param properties: The properties to drop the constraint from
306
+
307
+ :return: True if the constraint was successfully dropped, False otherwise.
308
+ """
309
+ command_arguments: CommandArgList = [graph, type]
310
+ if node is not None:
311
+ command_arguments.extend([PrefixToken.NODE, node])
312
+ if relationship is not None:
313
+ command_arguments.extend([PrefixToken.RELATIONSHIP, relationship])
314
+ if properties:
315
+ _props: list[StringT] = list(properties)
316
+ command_arguments.extend([PrefixToken.PROPERTIES, len(_props), *_props])
317
+
318
+ return self.client.create_request(
319
+ CommandName.GRAPH_CONSTRAINT_DROP,
320
+ *command_arguments,
321
+ callback=SimpleStringCallback(),
322
+ )
323
+
324
+ @module_command(
325
+ CommandName.GRAPH_CONSTRAINT_CREATE,
326
+ module=MODULE,
327
+ version_introduced="2.12.0",
328
+ group=COMMAND_GROUP,
329
+ )
330
+ def constraint_create(
331
+ self,
332
+ graph: KeyT,
333
+ type: Literal[PureToken.MANDATORY, PureToken.UNIQUE],
334
+ node: StringT | None = None,
335
+ relationship: StringT | None = None,
336
+ properties: Parameters[StringT] | None = None,
337
+ ) -> CommandRequest[bool]:
338
+ """
339
+ Creates a constraint on specified graph
340
+
341
+
342
+ :param graph: The name of the graph.
343
+ :param type: The type of constraint to create.
344
+ :param node: The label of the node to apply the constraint to.
345
+ :param relationship: The type of relationship to apply the constraint to.
346
+ :param properties: The properties to apply the constraint to.
347
+ :return: True if the constraint was created successfully, False otherwise.
348
+ """
349
+ command_arguments: CommandArgList = [graph, type]
350
+
351
+ if node is not None:
352
+ command_arguments.extend([PrefixToken.NODE, node])
353
+ if relationship is not None:
354
+ command_arguments.extend([PrefixToken.RELATIONSHIP, relationship])
355
+ if properties:
356
+ _props: list[StringT] = list(properties)
357
+ command_arguments.extend([PrefixToken.PROPERTIES, len(_props), *_props])
358
+ return self.client.create_request(
359
+ CommandName.GRAPH_CONSTRAINT_CREATE,
360
+ *command_arguments,
361
+ callback=SimpleStringCallback(ok_values={"PENDING"}),
362
+ )