Skip to content

Synchronous Client

Starting with version 2.1, Glide introduces a new synchronous Python client, alongside the existing default asynchronous client. Currently the sync client does not yet support the following features:

  • Pub/Sub
  • Cluster scan
  • Configuring an In-flight request limit
  • OpenTelemetry integration

Support for these features is on our roadmap and they are planned to be added in the next releases.

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.

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)