RedisGraph 命令¶
这些是与 RedisGraph 模块 交互的命令。下面是一个简短的示例,以及命令本身的文档。
创建一个图,添加两个节点(Create a graph, adding two nodes)
import redis
from redis.graph.node import Node
john = Node(label="person", properties={"name": "John Doe", "age": 33}
jane = Node(label="person", properties={"name": "Jane Doe", "age": 34}
r = redis.Redis()
graph = r.graph()
graph.add_node(john)
graph.add_node(jane)
graph.add_node(pat)
graph.commit()
- class redis.commands.graph.node.Node(node_id=None, alias=None, label=None, properties=None)[源代码]¶
A node within the graph.
- class redis.commands.graph.edge.Edge(src_node, relation, dest_node, edge_id=None, properties=None)[源代码]¶
An edge connecting two nodes.
- class redis.commands.graph.commands.GraphCommands[源代码]¶
RedisGraph Commands
- config(name, value=None, set=False)[源代码]¶
Retrieve or update a RedisGraph configuration. For more information see https://redis.io/commands/graph.config-get/.
Args:
- namestr
The name of the configuration
- value :
The value we want to set (can be used only when set is on)
- setbool
Turn on to set a configuration. Default behavior is get.
- execution_plan(query, params=None)[源代码]¶
Get the execution plan for given query, GRAPH.EXPLAIN returns an array of operations.
- 参数:
query -- the query that will be executed
params -- query parameters
- explain(query, params=None)[源代码]¶
Get the execution plan for given query, GRAPH.EXPLAIN returns ExecutionPlan object. For more information see GRAPH.EXPLAIN. # noqa
- 参数:
query -- the query that will be executed
params -- query parameters
- list_keys()[源代码]¶
Lists all graph keys in the keyspace. For more information see GRAPH.LIST. # noqa
- profile(query)[源代码]¶
Execute a query and produce an execution plan augmented with metrics for each operation's execution. Return a string representation of a query execution plan, with details on results produced by and time spent in each operation. For more information see GRAPH.PROFILE. # noqa
- query(q, params=None, timeout=None, read_only=False, profile=False)[源代码]¶
Executes a query against the graph. For more information see GRAPH.QUERY. # noqa
Args:
- qstr
The query.
- paramsdict
Query parameters.
- timeoutint
Maximum runtime for read queries in milliseconds.
- read_onlybool
Executes a readonly query if set to True.
- profilebool
Return details on results produced by and time spent in each operation.
- slowlog()[源代码]¶
Get a list containing up to 10 of the slowest queries issued against the given graph ID. For more information see GRAPH.SLOWLOG. # noqa
Each item in the list has the following structure: 1. A unix timestamp at which the log entry was processed. 2. The issued command. 3. The issued query. 4. The amount of time needed for its execution, in milliseconds.