Quick Start
Quick Start
Section titled “Quick Start”Installation
Section titled “Installation”npm i @valkey/valkey-glideBasic Examples
Section titled “Basic Examples”Standalone Mode:
Section titled “Standalone Mode:”import { GlideClient, GlideClusterClient, Logger } from "@valkey/valkey-glide";// When Valkey is in standalone mode, add address of the primary node, and any replicas you'd like to be able to read from.const addresses = [ { host: "localhost", port: 6379, },];// Check `GlideClientConfiguration/GlideClusterClientConfiguration` for additional options.const client = await GlideClient.createClient({ addresses: addresses, // if the server uses TLS, you'll need to enable it. Otherwise, the connection attempt will time out silently. // useTLS: true, // It is recommended to set a timeout for your specific use case requestTimeout: 500, // 500ms timeout clientName: "test_standalone_client",});// The empty array signifies that there are no additional arguments.const pong = await client.customCommand(["PING"]);console.log(pong);const set_response = await client.set("foo", "bar");console.log(`Set response is = ${set_response}`);const get_response = await client.get("foo");console.log(`Get response is = ${get_response}`);Cluster Mode:
Section titled “Cluster Mode:”import { GlideClient, GlideClusterClient, Logger } from "@valkey/valkey-glide";// When Valkey is in cluster mode, add address of any nodes, and the client will find all nodes in the cluster.const addresses = [ { host: "localhost", port: 6379, },];// Check `GlideClientConfiguration/GlideClusterClientConfiguration` for additional options.const client = await GlideClusterClient.createClient({ addresses: addresses, // if the cluster nodes use TLS, you'll need to enable it. Otherwise the connection attempt will time out silently. // useTLS: true, // It is recommended to set a timeout for your specific use case requestTimeout: 500, // 500ms timeout clientName: "test_cluster_client",});// The empty array signifies that there are no additional arguments.const pong = await client.customCommand(["PING"], { route: "randomNode" });console.log(pong);const set_response = await client.set("foo", "bar");console.log(`Set response is = ${set_response}`);const get_response = await client.get("foo");console.log(`Get response is = ${get_response}`);client.close();Supported platforms
Section titled “Supported platforms”Currently, the package is tested on:
| Operation systems | C lib | Architecture |
|---|---|---|
Linux | glibc, musl libc | x86_64, arm64 |
macOS | Darwin | x86_64, arm64 |
Community and Feedback
Section titled “Community and Feedback”We encourage you to join our community to support, share feedback, and ask questions. You can approach us for anything on our Valkey Slack: Join Valkey Slack.