diff --git a/.wordlist.txt b/.wordlist.txt index 2785e12..fa9da80 100644 --- a/.wordlist.txt +++ b/.wordlist.txt @@ -203,11 +203,14 @@ keyspace lTrim labelsList len +listGraphs +list_graphs lon malte matchRegEx maxCost maxLen +memoryUsage multithreaded myGraph myPassword @@ -270,6 +273,7 @@ schemas shortestPath signum slowlog +slowLog sourceNode sqrt stDev diff --git a/commands/graph.list.md b/commands/graph.list.md index ffa20d3..53ed781 100644 --- a/commands/graph.list.md +++ b/commands/graph.list.md @@ -10,6 +10,54 @@ parent: "Commands" Lists all graph keys in the keyspace. +## Examples + +{% capture shell_0 %} +GRAPH.LIST +{% endcapture %} + +{% capture python_0 %} +from falkordb import FalkorDB +db = FalkorDB(host='localhost', port=6379) +graphs = db.list_graphs() +print(graphs) +{% endcapture %} + +{% capture javascript_0 %} +import { FalkorDB } from 'falkordb'; +const db = await FalkorDB.connect({ + socket: { host: 'localhost', port: 6379 } +}); +const graphs = await db.list(); +console.log(graphs); +{% endcapture %} + +{% capture java_0 %} +import com.falkordb.*; + +Driver driver = FalkorDB.driver("localhost", 6379); +List graphs = driver.listGraphs(); +System.out.println(graphs); +{% endcapture %} + +{% capture rust_0 %} +use falkordb::{FalkorClientBuilder, FalkorConnectionInfo}; + +let connection_info: FalkorConnectionInfo = "falkor://127.0.0.1:6379" + .try_into() + .expect("Invalid connection info"); +let client = FalkorClientBuilder::new() + .with_connection_info(connection_info) + .build() + .expect("Failed to build client"); +let graphs = client.list_graphs(); +println!("{:?}", graphs); +{% endcapture %} + +{% include code_tabs.html id="list_tabs" shell=shell_0 python=python_0 javascript=javascript_0 java=java_0 rust=rust_0 %} + +### Sample Output + ```sh 127.0.0.1:6379> GRAPH.LIST 2) G diff --git a/commands/graph.memory.md b/commands/graph.memory.md index 4555078..7533838 100644 --- a/commands/graph.memory.md +++ b/commands/graph.memory.md @@ -46,16 +46,38 @@ The command returns an array of key-value pairs, where each pair represents a sp ## Examples ### Basic Usage -```bash + +{% capture shell_0 %} GRAPH.MEMORY USAGE myGraph -``` +{% endcapture %} + +{% capture javascript_0 %} +import { FalkorDB } from 'falkordb'; +const db = await FalkorDB.connect({ + socket: { host: 'localhost', port: 6379 } +}); +const graph = db.selectGraph('myGraph'); +const memoryInfo = await graph.memoryUsage(); +console.log(memoryInfo); +{% endcapture %} + +{% include code_tabs.html id="memory_basic_tabs" shell=shell_0 javascript=javascript_0 %} ### With Sampling -```bash + +{% capture shell_1 %} GRAPH.MEMORY USAGE myGraph SAMPLES 500 -``` +{% endcapture %} + +{% capture javascript_1 %} +const memoryInfo = await graph.memoryUsage({ samples: 500 }); +console.log(memoryInfo); +{% endcapture %} + +{% include code_tabs.html id="memory_samples_tabs" shell=shell_1 javascript=javascript_1 %} ### Sample Output + ```sh 127.0.0.1:6379> GRAPH.MEMORY USAGE flights 1) "total_graph_sz_mb" diff --git a/commands/graph.ro-query.md b/commands/graph.ro-query.md index 715ad5d..7caf1a1 100644 --- a/commands/graph.ro-query.md +++ b/commands/graph.ro-query.md @@ -25,6 +25,21 @@ GRAPH.RO_QUERY us_government "MATCH (p:president)-[:born]->(:state {name:'Hawaii graph.ro_query("MATCH (p:president)-[:born]->(:state {name:'Hawaii'}) RETURN p") {% endcapture %} -{% include code_tabs.html id="tabs_0" shell=shell_0 python=python_0 %} +{% capture javascript_0 %} +const result = await graph.ro_query("MATCH (p:president)-[:born]->(:state {name:'Hawaii'}) RETURN p"); +console.log(result); +{% endcapture %} + +{% capture java_0 %} +ResultSet result = graph.readOnlyQuery("MATCH (p:president)-[:born]->(:state {name:'Hawaii'}) RETURN p"); +System.out.println(result); +{% endcapture %} + +{% capture rust_0 %} +let result = graph.ro_query(r#"MATCH (p:president)-[:born]->(:state {name:'Hawaii'}) RETURN p"#).execute().await?; +println!("{:?}", result); +{% endcapture %} + +{% include code_tabs.html id="tabs_0" shell=shell_0 python=python_0 javascript=javascript_0 java=java_0 rust=rust_0 %} Query-level timeouts can be set as described in [the configuration section](/configuration#timeout). diff --git a/commands/graph.slowlog.md b/commands/graph.slowlog.md index 4e35c98..28040bf 100644 --- a/commands/graph.slowlog.md +++ b/commands/graph.slowlog.md @@ -16,6 +16,36 @@ Each item in the list has the following structure: 3. The issued query. 4. The amount of time needed for its execution, in milliseconds. +## Examples + +### Get slowlog + +{% capture shell_0 %} +GRAPH.SLOWLOG graph_id +{% endcapture %} + +{% capture python_0 %} +from falkordb import FalkorDB +db = FalkorDB(host='localhost', port=6379) +graph = db.select_graph('graph_id') +slowlog = graph.slowlog() +print(slowlog) +{% endcapture %} + +{% capture javascript_0 %} +import { FalkorDB } from 'falkordb'; +const db = await FalkorDB.connect({ + socket: { host: 'localhost', port: 6379 } +}); +const graph = db.selectGraph('graph_id'); +const slowlog = await graph.slowLog(); +console.log(slowlog); +{% endcapture %} + +{% include code_tabs.html id="slowlog_tabs" shell=shell_0 python=python_0 javascript=javascript_0 %} + +### Sample Output + ```sh GRAPH.SLOWLOG graph_id 1) 1) "1581932396" @@ -28,10 +58,16 @@ GRAPH.SLOWLOG graph_id 4) "0.288" ``` -To reset a graph's slowlog issue the following command: +### Reset slowlog -```sh +{% capture shell_1 %} GRAPH.SLOWLOG graph_id RESET -``` +{% endcapture %} + +{% capture python_1 %} +graph.slowlog_reset() +{% endcapture %} + +{% include code_tabs.html id="slowlog_reset_tabs" shell=shell_1 python=python_1 %} Once cleared the information is lost forever.