Skip to content

Synchronous Client

Starting with version 2.1, Glide introduces a new synchronous Python client, alongside the existing default asynchronous client.

The following features were added to the sync client in subsequent releases:

FeatureVersion
Cluster Scanv2.2.0
In-flight Request Limitv2.3.0
OpenTelemetryv2.3.0
PubSubv2.3.0

The synchronous Python GLIDE client is available through pypi.

pip install valkey-glide-sync

The synchronous client is located under the glide_sync module. Its API is similar to the asynchronous client making it interchangeable in most cases with the exception of not having to use the await keyword.

The following example compares the synchronous vs asynchronous clients usage for a standalone configuration.

from glide_sync import (
GlideClient,
GlideClientConfiguration,
NodeAddress,
BatchOptions,
Batch
)
addresses = [
NodeAddress(host="primary.example.com", port=6379),
NodeAddress(host="replica1.example.com", port=6379),
NodeAddress(host="replica2.example.com", port=6379)
]
client_config = GlideClientConfiguration(addresses)
client = GlideClient.create(client_config)
# Configure batch options
options = BatchOptions(timeout=2000) # 2-second timeout
pipeline = Batch()
pipeline.set("key1", "value1")
results = client.exec(pipeline, options=options)
print("Pipeline Results:", results)