Connection Options
Valkey GLIDE maintains consistent and intuitive configuration across all supported languages. This guides will go over how connection configurations are handled across clients and listing the available options.
Configuration Options
Section titled “Configuration Options”GLIDE clients uses configuration objects to configure connections to Valkey. This keeps a consistent interface
between clients while staying within the idiomatic norms of each specific programming language.
The following are the configuration references for each Glide clients:
| Language | Standalone Mode | Cluster Mode |
|---|---|---|
| Java | Reference | Reference |
| Node.js | Reference | Reference |
| Python | Reference | Reference |
| Go | Reference | Reference |
| PHP | Reference | Reference |
| C# | Reference | Reference |
| Ruby | Reference | Reference |
Example
Section titled “Example”from glide import GlideClientConfiguration, NodeAddress
config = GlideClientConfiguration( addresses=[NodeAddress("localhost", 6379)], use_tls=False, request_timeout=1000, client_name="python_app")import { GlideClientOptions } from "@valkey/valkey-glide";
const config: GlideClientOptions = { addresses: [{ host: "localhost", port: 6379 }], useTLS: false, requestTimeout: 1000, clientName: "node_app"};import glide.api.models.configuration.GlideClientConfiguration;import glide.api.models.configuration.NodeAddress;
GlideClientConfiguration config = GlideClientConfiguration.builder() .address(NodeAddress.builder().host("localhost").port(6379).build()) .useTLS(false) .requestTimeout(1000) .clientName("java_app") .build();import "github.com/valkey-io/valkey-glide/go/v2/config"
conf := config.NewClientConfiguration(). WithAddress(&config.NodeAddress{Host: "localhost", Port: 6380}). WithUseTLS(false). WithRequestTimeout(1000). WithClientName("go_app")Requirements: PHP 8.1+
$client = new ValkeyGlide();$client->connect( addresses: [['host' => 'localhost', 'port' => 6379]], use_tls: false, request_timeout: 1000, client_name: 'php_app');using Valkey.Glide;using static Valkey.Glide.ConnectionConfiguration;
var config = new StandaloneClientConfigurationBuilder() .WithAddress("localhost", 6379) .WithRequestTimeout(TimeSpan.FromMilliseconds(1000)) .WithClientName("csharp_app") .Build();require "valkey"
client = Valkey.new( host: "localhost", port: 6379, ssl: false, timeout: 1.0, # Request timeout in seconds client_name: "ruby_app")Client library identification
Section titled “Client library identification”Standalone and cluster configurations can customize the library name reported by CLIENT INFO.
The library-name override replaces the binding’s default base name, while the client
information tag appends attribution in parentheses. Non-empty library-name overrides and
client information tags must contain only printable ASCII characters from ! (U+0021)
through ~ (U+007E), excluding ( and ).
| Client | Default library name |
|---|---|
| Go | GlideGo |
| Java | GlideJava |
| Python async | GlidePy |
| Python sync | GlidePySync |
| Node.js | GlideJS |
Choose the option that matches how the connection should be identified:
- Client information tag only (
client_info_tagorclientInfoTag) — Appends a parenthesized tag while retaining GLIDE’s default identity, for exampleGlidePy(my-framework:1.2.3). This is recommended for libraries and frameworks that embed GLIDE because it attributes the embedding layer while the connection still counts toward GLIDE-level adoption metrics. - Library-name override only (
lib_nameorlibName) — Replaces the default name, for examplecustom-client. Use this only when the connection should be presented as a different client, such as through a compatibility layer. The reported name no longer indicates that GLIDE is underneath. - Both — Uses the library-name override as the base and appends the client information tag,
for example
custom-client(my-framework:1.2.3). This combination is uncommon.
The asynchronous and synchronous clients use the same configuration fields:
from glide import ( GlideClientConfiguration, GlideClusterClientConfiguration, NodeAddress,)
standalone_config = GlideClientConfiguration( addresses=[NodeAddress("localhost", 6379)], lib_name="custom-client", client_info_tag="framework:1.2",)
cluster_config = GlideClusterClientConfiguration( addresses=[NodeAddress("localhost", 7001)], lib_name="custom-client", client_info_tag="framework:1.2",)Invalid values raise ValueError when the configuration is constructed.
A dedicated asynchronous standalone monitor uses the same configuration:
from glide import MonitorClient
monitor = await MonitorClient.create(standalone_config)try: # Consume monitor messages. passfinally: await monitor.aclose()The synchronous client provides the equivalent API:
from glide_sync import GlideClientConfiguration, MonitorClient, NodeAddress
standalone_config = GlideClientConfiguration( addresses=[NodeAddress("localhost", 6379)], lib_name="custom-client", client_info_tag="framework:1.2",)
with MonitorClient.create(standalone_config) as monitor: # Consume monitor messages. passThe asynchronous and synchronous clients use the same configuration methods:
GlideClientConfiguration standaloneConfig = GlideClientConfiguration.builder() .address( NodeAddress.builder() .host("localhost") .port(6379) .build()) .libName("custom-client") .clientInfoTag("framework:1.2") .build();
GlideClusterClientConfiguration clusterConfig = GlideClusterClientConfiguration.builder() .address( NodeAddress.builder() .host("localhost") .port(7001) .build()) .libName("custom-client") .clientInfoTag("framework:1.2") .build();Invalid values raise IllegalArgumentException when libName or clientInfoTag is called.
A dedicated standalone monitor uses the same configuration:
try (MonitorClient monitor = MonitorClient.create(standaloneConfig)) { // Consume monitor messages.}The asynchronous and synchronous clients use the same configuration fields:
import { GlideClientConfiguration, GlideClusterClientConfiguration,} from "@valkey/valkey-glide";
const standaloneConfig: GlideClientConfiguration = { addresses: [{ host: "localhost", port: 6379 }], libName: "custom-client", clientInfoTag: "framework:1.2",};
const clusterConfig: GlideClusterClientConfiguration = { addresses: [{ host: "localhost", port: 7001 }], libName: "custom-client", clientInfoTag: "framework:1.2",};Invalid values cause client creation to reject with a ConfigurationError.
A dedicated standalone monitor uses the same configuration:
import { GlideMonitorClient } from "@valkey/valkey-glide";
const monitor = await GlideMonitorClient.create(standaloneConfig);
try { // Consume monitor messages.} finally { await monitor.close();}The asynchronous and synchronous clients use the same configuration functions:
standaloneConfig := config.NewClientConfiguration(). WithAddress(&config.NodeAddress{Host: "localhost", Port: 6379}). WithLibName("custom-client"). WithClientInfoTag("framework:1.2")
clusterConfig := config.NewClusterClientConfiguration(). WithAddress(&config.NodeAddress{Host: "localhost", Port: 7001}). WithLibName("custom-client"). WithClientInfoTag("framework:1.2")Invalid values cause client creation to return an error.
A dedicated standalone monitor uses the same configuration:
monitor, err := glide.NewMonitorClient(standaloneConfig, nil)if err != nil { // Handle the connection error. return}defer monitor.Close()