Quick start
Valkey GLIDE is the open-source client library for Valkey. Designed for performance and consistency between supported languages. This guide will show how to quickly install and set up a simple development environment for Valkey GLIDE.
Understanding GLIDE Clients
Section titled “Understanding GLIDE Clients”GLIDE provides two main client types:
GlideClient: For standalone Valkey instances.GlideClusterClient: For cluster deployments.
For this guide, we will use a standalone client to connect to a Valkey Docker instance.
Setting Up
Section titled “Setting Up”-
Follow the instructions on the Docker website to install Docker for your operating system.
-
Start a local Valkey server:
Terminal window # Pull and run Valkey serverdocker run -d --name valkey-server -p 6379:6379 valkey/valkey:latest# Verify it's runningdocker ps -
Verify connection with Valkey server:
Terminal window docker exec valkey-server valkey-cli ping# Expected output: PONG
System Requirements
Section titled “System Requirements”- Ubuntu 20 (x86_64/amd64 and arm64/aarch64)
- Amazon Linux 2 (AL2) and 2023 (AL2023) (x86_64)
- macOS 14.7 (Apple silicon/aarch_64)
- macOS 13.7 (x86_64/amd64)
Install Valkey GLIDE
Section titled “Install Valkey GLIDE”Requirements: Python 3.9 to 3.13.
# Install the latest versionpip3 install valkey-glideRequirements: JDK 11+
Add the following to your build tool. Make sure to specify your classifier for your OS.
plugins { id "com.google.osdetector" version "1.7.3"}dependencies { implementation group: 'io.valkey', name: 'valkey-glide', version: '2.+', classifier: osdetector.classifier}<!-- with os-maven-plugin --><build> <extensions> <extension> <groupId>kr.motd.maven</groupId> <artifactId>os-maven-plugin</artifactId> </extension> </extensions></build><dependencies> <dependency> <groupId>io.valkey</groupId> <artifactId>valkey-glide</artifactId> <classifier>${os.detected.classifier}</classifier> <version>[2.0.0,)</version> </dependency></dependencies>// Specify the OS classifier for your system.libraryDependencies += "io.valkey" % "valkey-glide" % "2.+" classifier "<your-classifier>"Requirements: Node 16+
npm install @valkey/valkey-glideRequirements: Go 1.22+
# Initialize a new Go module (if needed)go mod init your-project-name
# Install GLIDEgo get github.com/valkey-io/valkey-glide/goA Simple Ping
Section titled “A Simple Ping”The following code snippet performs a simple “ping” command to our docker Valkey instance. This will tell us that
GLIDE was able to send and receive commands from Valkey.
For testing against a live instance, update the GlideClient configurations.
import asynciofrom glide import GlideClient, NodeAddress
async def main(): # Create client configuration client = GlideClient([NodeAddress("localhost", 6379)])
try: # Test the connection response = await client.ping()
# Valkey responds with PONG print(f"Connected! Server responded: {response}")
except Exception as e: print(f"Connection failed: {e}")
finally: # Always close the client await client.close()
# Run the async functionif __name__ == "__main__": asyncio.run(main())import glide.api.GlideClient;import glide.api.models.configuration.GlideClientConfiguration;import glide.api.models.configuration.NodeAddress;
public class ConnectionTest { public static void main(String[] args) { // Create client configuration GlideClientConfiguration config = GlideClientConfiguration.builder() .address(NodeAddress.builder() .host("localhost") .port(6379) .build()) .build();
try (GlideClient client = GlideClient.createClient(config).get()) { // Test the connection String response = client.ping().get();
// Valkey responds with PONG System.out.println("Connected! Server responded: " + response);
} catch (Exception e) { System.err.println("Connection failed: " + e.getMessage()); } }}const { GlideClient } = require('@valkey/valkey-glide');
async function main() { // Create client configuration const client = GlideClient.createClient({ addresses: [{ host: 'localhost', port: 6379 }] });
try { // Test the connection const response = await client.ping();
// Valkey responds with PONG console.log(`Connected! Server responded: ${response}`);
} catch (error) { console.error(`Connection failed: ${error.message}`); } finally { // Always close the client client.close(); }}
// Run the functionmain().catch(console.error);package main
import ( "fmt" "log"
"github.com/valkey-io/valkey-glide/go/glide/api")
func main() { // Create client configuration config := &api.GlideClientConfiguration{ Addresses: []api.NodeAddress{ {Host: "localhost", Port: 6379}, }, }
client := api.NewGlideClient(config) defer client.Close()
// Test the connection response, err := client.Ping() if err != nil { log.Fatalf("Connection failed: %v", err) }
// Valkey responds with PONG fmt.Printf("Connected! Server responded: %s\n", response)}Running the above snippet should give you this response.
Connected! Server responded: PONGConnection Configuration
Section titled “Connection Configuration”GLIDE offers many configuration options to connect to Valkey through its configuration objects.
These options, and other interfaces, stay consistent between languages.
# Setting up connection configurationconfig = GlideClientConfiguration( addresses=[NodeAddress("localhost", 6379)], # Connection timeout (milliseconds) request_timeout=5000, # Connection pool size connection_backoff_max_delay=1000, # TLS configuration (if needed) use_tls=False, # Database selection (0-15 for Redis/Valkey) database_id=0)// Setting up connection configurationGlideClientConfiguration config = GlideClientConfiguration.builder() .address(NodeAddress.builder() .host("localhost") .port(6379) .build()) // Connection timeout .requestTimeout(Duration.ofSeconds(5)) // TLS configuration (if needed) .useTls(false) // Database selection .databaseId(0) .build();// Setting up connection configurationconst configs = { addresses: [{ host: 'localhost', port: 6379 }], // Connection timeout (milliseconds) requestTimeout: 5000, // TLS configuration (if needed) useTls: false, // Database selection (0-15 for Redis/Valkey) databaseId: 0}// Setting up connection configurationconfig := &api.GlideClientConfiguration{ Addresses: []api.NodeAddress{ {Host: "localhost", Port: 6379}, }, // Connection timeout RequestTimeout: 5 * time.Second, // TLS configuration (if needed) UseTls: false, // Database selection DatabaseId: 0,}Next Steps
Section titled “Next Steps”Congratulations, you are now connected to Valkey using GLIDE! To see how to make basic operations take a look at the our guide.