Skip to main content

Valkey GLIDE Async client. Supports Valkey and Redis OSS.

Project description

Welcome to Valkey GLIDE!

Valkey General Language Independent Driver for the Enterprise (GLIDE) is the official open-source Valkey client library, proudly part of the Valkey organization. Our mission is to make your experience with Valkey and Redis OSS seamless and enjoyable. Whether you're a seasoned developer or just starting out, Valkey GLIDE is here to support you every step of the way.

Why Choose Valkey GLIDE?

  • Community and Open Source: Join our vibrant community and contribute to the project. We are always here to respond, and the client is for the community.
  • Reliability: Built with best practices learned from over a decade of operating Redis OSS-compatible services.
  • Performance: Optimized for high performance and low latency.
  • High Availability: Designed to ensure your applications are always up and running.
  • Cross-Language Support: Implemented using a core driver framework written in Rust, with language-specific extensions to ensure consistency and reduce complexity.
  • Stability and Fault Tolerance: We brought our years of experience to create a bulletproof client.
  • Backed and Supported by AWS and GCP: Ensuring robust support and continuous improvement of the project.

Documentation

See GLIDE's Python documentation site.

Supported Engine Versions

Refer to the Supported Engine Versions table for details.

Getting Started - Python Wrapper

System Requirements

The release of Valkey GLIDE was tested on the following platforms:

Linux:

  • Ubuntu 20 (x86_64/amd64 and arm64/aarch64)
  • Amazon Linux 2 (AL2) and 2023 (AL2023) (x86_64)

Note: Currently Alpine Linux / MUSL is NOT supported.

macOS:

  • macOS 14.7 (Apple silicon/aarch_64)
  • macOS 13.7 (x86_64/amd64)

Python Supported Versions

Python Version
3.9
3.10
3.11
3.12
3.13

Valkey GLIDE transparently supports both the asyncio and trio concurrency frameworks.

Installation and Setup

✅ Async Client

To install the async version:

pip install valkey-glide

Verify installation:

python3
>>> import glide

✅ Sync Client

To install the sync version:

pip install valkey-glide-sync

Verify installation:

python3
>>> import glide_sync

Basic Examples

🔁 Async Client

✅ Async Cluster Mode

import asyncio
from glide import GlideClusterClientConfiguration, NodeAddress, GlideClusterClient

async def test_cluster_client():
    addresses = [NodeAddress("address.example.com", 6379)]
    # It is recommended to set a timeout for your specific use case
    config = GlideClusterClientConfiguration(addresses, request_timeout=500)  # 500ms timeout
    client = await GlideClusterClient.create(config)
    set_result = await client.set("foo", "bar")
    print(f"Set response is {set_result}")
    get_result = await client.get("foo")
    print(f"Get response is {get_result}")

asyncio.run(test_cluster_client())

✅ Async Standalone Mode

import asyncio
from glide import GlideClientConfiguration, NodeAddress, GlideClient

async def test_standalone_client():
    addresses = [
        NodeAddress("server_primary.example.com", 6379),
        NodeAddress("server_replica.example.com", 6379)
    ]
    # It is recommended to set a timeout for your specific use case
    config = GlideClientConfiguration(addresses, request_timeout=500)  # 500ms timeout
    client = await GlideClient.create(config)
    set_result = await client.set("foo", "bar")
    print(f"Set response is {set_result}")
    get_result = await client.get("foo")
    print(f"Get response is {get_result}")

asyncio.run(test_standalone_client())

🔂 Sync Client

✅ Sync Cluster Mode

from glide_sync import GlideClusterClientConfiguration, NodeAddress, GlideClusterClient

def test_cluster_client():
    addresses = [NodeAddress("address.example.com", 6379)]
    # It is recommended to set a timeout for your specific use case
    config = GlideClusterClientConfiguration(addresses, request_timeout=500)  # 500ms timeout
    client = GlideClusterClient.create(config)
    set_result = client.set("foo", "bar")
    print(f"Set response is {set_result}")
    get_result = client.get("foo")
    print(f"Get response is {get_result}")

test_cluster_client()

✅ Sync Standalone Mode

from glide_sync import GlideClientConfiguration, NodeAddress, GlideClient

def test_standalone_client():
    addresses = [
        NodeAddress("server_primary.example.com", 6379),
        NodeAddress("server_replica.example.com", 6379)
    ]
    # It is recommended to set a timeout for your specific use case
    config = GlideClientConfiguration(addresses, request_timeout=500)  # 500ms timeout
    client = GlideClient.create(config)
    set_result = client.set("foo", "bar")
    print(f"Set response is {set_result}")
    get_result = client.get("foo")
    print(f"Get response is {get_result}")

test_standalone_client()

PubSub Configuration

Valkey GLIDE supports dynamic PubSub with automatic subscription reconciliation. Configure the reconciliation interval to ensure subscriptions remain synchronized:

# Async client
from glide import GlideClientConfiguration, NodeAddress, GlideClient, AdvancedGlideClientConfiguration

config = GlideClientConfiguration(
    addresses=[NodeAddress("localhost", 6379)],
    advanced_config=AdvancedGlideClientConfiguration(
        pubsub_reconciliation_interval=5000  # Reconcile every 5 seconds (in milliseconds)
    )
)
client = await GlideClient.create(config)

# Sync client
from glide_sync import GlideClientConfiguration, NodeAddress, GlideClient, AdvancedGlideClientConfiguration

config = GlideClientConfiguration(
    addresses=[NodeAddress("localhost", 6379)],
    advanced_config=AdvancedGlideClientConfiguration(
        pubsub_reconciliation_interval=5000  # Reconcile every 5 seconds (in milliseconds)
    )
)
client = GlideClient.create(config)

Pre-configured Subscriptions

You can configure subscriptions at client creation time. The client will automatically establish these subscriptions during connection:

# Async client with pre-configured subscriptions
from glide import (
    GlideClientConfiguration,
    NodeAddress,
    GlideClient,
)

def message_callback(msg, context):
    print(f"Received message on {msg.channel}: {msg.message}")

config = GlideClientConfiguration(
    addresses=[NodeAddress("localhost", 6379)],
    pubsub_subscriptions=GlideClientConfiguration.PubSubSubscriptions(
        channels_and_patterns={
            GlideClientConfiguration.PubSubChannelModes.Exact: {"news", "updates"},
            GlideClientConfiguration.PubSubChannelModes.Pattern: {"events.*", "logs.*"},
        },
        callback=message_callback,
        context=None  # Optional context passed to callback
    )
)
client = await GlideClient.create(config)

# Cluster client with sharded pubsub
from glide import GlideClusterClientConfiguration, GlideClusterClient

config = GlideClusterClientConfiguration(
    addresses=[NodeAddress("localhost", 6379)],
    pubsub_subscriptions=GlideClusterClientConfiguration.PubSubSubscriptions(
        channels_and_patterns={
            GlideClusterClientConfiguration.PubSubChannelModes.Exact: {"channel1"},
            GlideClusterClientConfiguration.PubSubChannelModes.Pattern: {"pattern*"},
            GlideClusterClientConfiguration.PubSubChannelModes.Sharded: {"shard_channel"},
        },
        callback=message_callback,
        context=None
    )
)
cluster_client = await GlideClusterClient.create(config)

Dynamic Subscription Management

Subscribe and unsubscribe at runtime:

# Subscribe to channels
await client.subscribe({"channel1", "channel2"}, timeout_ms=5000)

# Subscribe to patterns
await client.psubscribe({"news.*", "events.*"}, timeout_ms=5000)

# Unsubscribe from specific channels
await client.unsubscribe({"channel1"}, timeout_ms=5000)

# Unsubscribe from all channels
from glide.async_commands.core import ALL_CHANNELS
await client.unsubscribe(ALL_CHANNELS, timeout_ms=5000)

# Unsubscribe from all patterns
from glide.async_commands.core import ALL_PATTERNS
await client.punsubscribe(ALL_PATTERNS, timeout_ms=5000)

# Cluster: sharded pubsub
await cluster_client.ssubscribe({"shard_channel"}, timeout_ms=5000)
await cluster_client.sunsubscribe({"shard_channel"}, timeout_ms=5000)

# Check subscription state
state = await client.get_subscriptions()
print(f"Desired: {state.desired_subscriptions}")
print(f"Actual: {state.actual_subscriptions}")

Client Statistics

Monitor client performance and subscription health using get_statistics():

stats = await client.get_statistics()  # Async
# or
stats = client.get_statistics()  # Sync

# Available metrics:
# - total_connections: Number of active connections
# - total_clients: Number of client instances
# - total_values_compressed: Count of compressed values
# - total_values_decompressed: Count of decompressed values
# - total_original_bytes: Original data size before compression
# - total_bytes_compressed: Compressed data size
# - total_bytes_decompressed: Decompressed data size
# - compression_skipped_count: Times compression was skipped
# - subscription_out_of_sync_count: Failed reconciliation attempts
# - subscription_last_sync_timestamp: Last successful sync (milliseconds since epoch)

OpenTelemetry Configuration

Valkey GLIDE supports OpenTelemetry for distributed tracing and metrics collection. This allows you to monitor command execution, measure latency, and track performance across your application.

Basic OpenTelemetry Setup

Both async and sync clients support OpenTelemetry configuration:

# Async client
from glide import OpenTelemetry, OpenTelemetryConfig, OpenTelemetryTracesConfig, OpenTelemetryMetricsConfig

# Sync client
from glide_sync import OpenTelemetry, OpenTelemetryConfig, OpenTelemetryTracesConfig, OpenTelemetryMetricsConfig

# Initialize OpenTelemetry (once per process)
OpenTelemetry.init(OpenTelemetryConfig(
    traces=OpenTelemetryTracesConfig(
        endpoint="http://localhost:4318/v1/traces",  # OTLP HTTP endpoint
        sample_percentage=1  # Sample 1% of requests (default)
    ),
    metrics=OpenTelemetryMetricsConfig(
        endpoint="http://localhost:4318/v1/metrics"
    ),
    flush_interval_ms=5000  # Flush every 5 seconds (default)
))

Supported Endpoints

  • HTTP/HTTPS: http://localhost:4318/v1/traces or https://...
  • gRPC: grpc://localhost:4317
  • File: file:///tmp/traces.json (for local testing)

Runtime Configuration

You can adjust the sampling percentage at runtime:

# Change sampling to 10%
OpenTelemetry.set_sample_percentage(10)

# Check current sampling rate
current_rate = OpenTelemetry.get_sample_percentage()

Note: OpenTelemetry can only be initialized once per process. To change configuration, restart your application.


Compression Configuration (EXPERIMENTAL)

⚠️ WARNING: This feature is experimental and can result in incorrect responses from certain commands without careful use.

Valkey GLIDE supports automatic compression and decompression of string values to reduce memory usage and network bandwidth.

Incompatible Commands: Compression is NOT compatible with commands that manipulate string data on the server:

  • APPEND, GETRANGE, SETRANGE, STRLEN, LCS
  • INCR, INCRBY, INCRBYFLOAT, DECR, DECRBY
  • GETBIT, SETBIT, BITCOUNT, BITPOS, BITFIELD, BITFIELD_RO, BITOP

Using these commands with compressed values will result in incorrect behavior or errors.

Basic Compression Setup

# Async client
from glide import GlideClientConfiguration, NodeAddress, GlideClient, CompressionConfiguration, CompressionBackend

config = GlideClientConfiguration(
    addresses=[NodeAddress("localhost", 6379)],
    compression_configuration=CompressionConfiguration(
        backend=CompressionBackend.ZSTD,  # or CompressionBackend.LZ4
        min_compression_size=64,  # Only compress values >= 64 bytes
        compression_level=3  # ZSTD: 1-22, LZ4: -128 to 12
    )
)
client = await GlideClient.create(config)

# Sync client
from glide_sync import GlideClientConfiguration, NodeAddress, GlideClient, CompressionConfiguration, CompressionBackend

config = GlideClientConfiguration(
    addresses=[NodeAddress("localhost", 6379)],
    compression_configuration=CompressionConfiguration(
        backend=CompressionBackend.ZSTD,
        min_compression_size=64,
        compression_level=3
    )
)
client = GlideClient.create(config)

Supported Commands

Write Commands (automatic compression):

  • SET, MSET, SETEX, PSETEX, SETNX

Read Commands (automatic decompression):

  • GET, MGET, GETEX, GETDEL

Monitoring Compression

Use get_statistics() to monitor compression effectiveness:

stats = await client.get_statistics()  # or client.get_statistics() for sync
print(f"Values compressed: {stats['total_values_compressed']}")
print(f"Original bytes: {stats['total_original_bytes']}")
print(f"Compressed bytes: {stats['total_bytes_compressed']}")
print(f"Compression skipped: {stats['compression_skipped_count']}")

For complete examples with error handling, please refer to:

Building & Testing

Development instructions for local building & testing the package are in the DEVELOPER.md file.

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.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

valkey_glide-2.4.0rc3-cp313-cp313-macosx_10_7_x86_64.whl (7.4 MB view details)

Uploaded CPython 3.13macOS 10.7+ x86-64

valkey_glide-2.4.0rc3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (7.7 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

valkey_glide-2.4.0rc3-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (7.2 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

valkey_glide-2.4.0rc3-cp312-cp312-macosx_11_0_arm64.whl (6.9 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

valkey_glide-2.4.0rc3-cp312-cp312-macosx_10_7_x86_64.whl (7.4 MB view details)

Uploaded CPython 3.12macOS 10.7+ x86-64

valkey_glide-2.4.0rc3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (7.7 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

valkey_glide-2.4.0rc3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (7.2 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

valkey_glide-2.4.0rc3-cp311-cp311-macosx_11_0_arm64.whl (6.9 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

valkey_glide-2.4.0rc3-cp311-cp311-macosx_10_7_x86_64.whl (7.4 MB view details)

Uploaded CPython 3.11macOS 10.7+ x86-64

valkey_glide-2.4.0rc3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (7.7 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

valkey_glide-2.4.0rc3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (7.2 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

valkey_glide-2.4.0rc3-cp310-cp310-macosx_11_0_arm64.whl (6.9 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

valkey_glide-2.4.0rc3-cp310-cp310-macosx_10_7_x86_64.whl (7.4 MB view details)

Uploaded CPython 3.10macOS 10.7+ x86-64

File details

Details for the file valkey_glide-2.4.0rc3-cp313-cp313-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for valkey_glide-2.4.0rc3-cp313-cp313-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 5f021821771268da039da3ef3e3f8197b23869ca68269beb92fe291627f5da07
MD5 1fa81415d09d8e9cdee3a8ade2841fe2
BLAKE2b-256 1ca466c7e513efdb8bb7baa7667e1fbdbba582af5738f55f35d8eec2e048e399

See more details on using hashes here.

File details

Details for the file valkey_glide-2.4.0rc3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for valkey_glide-2.4.0rc3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6f257b16b557c0110a455474456239981deb9805e131dbc65113b79d12f148bd
MD5 a74b48e25ad2d9d1f79a0d5cce29d6fb
BLAKE2b-256 0df94d30708153ca43c501ce67475dfa766283a34e73aa88938bb5904460bf1f

See more details on using hashes here.

File details

Details for the file valkey_glide-2.4.0rc3-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for valkey_glide-2.4.0rc3-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 0e294a08e4802d08fc48e709e352d494f729306584627a699f9d8840bc3cb6f7
MD5 14c2811e2c541adc13342f637adfe22d
BLAKE2b-256 9e4cca82b58599820ef8f6ce3d16aed8749284729ab7e81181d80f513055809e

See more details on using hashes here.

File details

Details for the file valkey_glide-2.4.0rc3-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for valkey_glide-2.4.0rc3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 be7a9e807d6d0d878fddfca310ba34de83f10c687fe19ea4573a08b7753999cf
MD5 4b7ec4a5c9c8560328b64762f38c5fd1
BLAKE2b-256 4395cf7839757f03c3709500c1371847bf9ed1ad19b1a43da53efc7b564abca8

See more details on using hashes here.

File details

Details for the file valkey_glide-2.4.0rc3-cp312-cp312-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for valkey_glide-2.4.0rc3-cp312-cp312-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 9091ad504d3e442bd3ec57f97085370182f4bf341b2eaafb91374ad05077eedc
MD5 ca51def21f67376289e0b2a83fc92cd1
BLAKE2b-256 d247281b4b7cf57dbf878293ebbdf4e7bcca61a61ae2e99d55c7fb5bb47bc0bf

See more details on using hashes here.

File details

Details for the file valkey_glide-2.4.0rc3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for valkey_glide-2.4.0rc3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9107fab52e4b279b9eca812974cb9079d5744ae1ee29e70205e3042ad0c9130a
MD5 95672fb9383d06d1f197bc2ad75d06bf
BLAKE2b-256 d5e9426021e07cffd89f46f1458b18eeca29763c2f763bd75e82b7570c883f5e

See more details on using hashes here.

File details

Details for the file valkey_glide-2.4.0rc3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for valkey_glide-2.4.0rc3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 fb4526947b4e91cb767109a8aeb4f69f45d3888942db5e03b4d6810ce0cbe2d6
MD5 6e81e21fb5fb7d9c8f22488df063d54b
BLAKE2b-256 b8981c5790bef591c33d9de2e064e62d67e421353dfa88d25f9e17aa2f620585

See more details on using hashes here.

File details

Details for the file valkey_glide-2.4.0rc3-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for valkey_glide-2.4.0rc3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5861e47729c38c8297f1fff429097ab9aed40adb5e8bb24b98fd9373629edfa1
MD5 97fa6f6c97293e2fb6d1332506e6db48
BLAKE2b-256 5723f9948cd5623f28d623870898aa267d34180564d8d16466e7aa9deffbdabc

See more details on using hashes here.

File details

Details for the file valkey_glide-2.4.0rc3-cp311-cp311-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for valkey_glide-2.4.0rc3-cp311-cp311-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 47126af513bc0c9df0706630c9949c1e671d4744e770f4f911ff5a5b2ac2540d
MD5 15e3b61da2498806ebbe7b989af41570
BLAKE2b-256 4fc68f693702c8884ec0ac81330c3850e1bb32a2436ca9fde1276319ab87d2df

See more details on using hashes here.

File details

Details for the file valkey_glide-2.4.0rc3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for valkey_glide-2.4.0rc3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1a8b8fe41139010e631bcf92f664e9483d92eab8da2c18d3ca037eb38f9b513a
MD5 9dee61abec6ef14d1196d5a22bea250b
BLAKE2b-256 3ec818a65f864f638c12a7d1d66bbee9cb3b133cc5a912a1d16d73aa83b27031

See more details on using hashes here.

File details

Details for the file valkey_glide-2.4.0rc3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for valkey_glide-2.4.0rc3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 5c52ef8a7897fa8ccb2c3fe21b87076d58c878f327b9ee9d6df50d80ece26e24
MD5 33b6279aac660d0283146a051cbacd62
BLAKE2b-256 681e51c63af9286ca77ac7cdbb6d988b7408550092d70134b70a08cff9fc978b

See more details on using hashes here.

File details

Details for the file valkey_glide-2.4.0rc3-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for valkey_glide-2.4.0rc3-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b396ecb04543011818568100cddf49909f58f89823e61c4154e3dbaedf44060b
MD5 254c0c7a6e8ea2b2f8c9474d9bd0beb2
BLAKE2b-256 c2ce9efa3786633c7ca8e2cc82f560878d8b829407b891294a27201f77e5ee3c

See more details on using hashes here.

File details

Details for the file valkey_glide-2.4.0rc3-cp310-cp310-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for valkey_glide-2.4.0rc3-cp310-cp310-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 fe405494ef349b7714d989439a78e0489a770215b44050ec8c4b37d39571277c
MD5 9dfcb79ead8de4a143b390ef8da1eda1
BLAKE2b-256 df5bed3fd3078704cf69d5e819a8a4d453e6e9bbb7e75b079b992f3d760bb0a6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page