{"id":3313,"library":"valkey-glide-sync","title":"Valkey GLIDE Sync Client","description":"Valkey GLIDE Sync is an official open-source Valkey client library for Python, designed to interact with Valkey and Redis OSS in a synchronous manner. It supports both standalone and cluster deployments, offering features like automatic topology discovery, read-from-replica options, and OpenTelemetry integration. The library is part of the Valkey organization and aims for high performance and reliability, currently at version 2.3.1.","status":"active","version":"2.3.1","language":"en","source_language":"en","source_url":"https://github.com/valkey-io/valkey-glide","tags":["database","Valkey","Redis","client","sync","data-store"],"install":[{"cmd":"pip install valkey-glide-sync","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"note":"The `glide` package is for the asynchronous client. The synchronous client classes are in `glide_sync`.","wrong":"from glide import GlideClient","symbol":"GlideClient","correct":"from glide_sync import GlideClient"},{"note":"The `glide` package is for the asynchronous client. The synchronous client classes are in `glide_sync`.","wrong":"from glide import GlideClusterClient","symbol":"GlideClusterClient","correct":"from glide_sync import GlideClusterClient"},{"symbol":"GlideClientConfiguration","correct":"from glide_sync import GlideClientConfiguration"},{"symbol":"NodeAddress","correct":"from glide_sync import NodeAddress"}],"quickstart":{"code":"import os\nfrom glide_sync import GlideClient, GlideClientConfiguration, NodeAddress\n\n# Configure connection details (e.g., from environment variables)\nHOST = os.environ.get('GLIDE_HOST', 'localhost')\nPORT = int(os.environ.get('GLIDE_PORT', '6379'))\nPASSWORD = os.environ.get('GLIDE_PASSWORD', '') # Optional\n\n# For Standalone client\nconfig = GlideClientConfiguration(\n    addresses=[NodeAddress(host=HOST, port=PORT)],\n    password=PASSWORD if PASSWORD else None # Set password only if provided\n)\n\n# Create and connect the client (sync method)\ntry:\n    client = GlideClient.create(config).get()\n    response = client.ping().get()\n    print(f\"Ping response: {response}\")\n    \n    client.set('mykey', 'myvalue').get()\n    value = client.get('mykey').get()\n    print(f\"Retrieved value for 'mykey': {value}\")\n    \nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\nfinally:\n    if 'client' in locals() and client:\n        client.close()\n","lang":"python","description":"This quickstart demonstrates how to connect to a standalone Valkey or Redis OSS instance using the synchronous Glide client, perform a simple PING, SET, and GET operation, and then close the client. It uses environment variables for host and port, falling back to localhost:6379 for local testing. Remember to use `.get()` to retrieve results from the synchronous client's future-like return values."},"warnings":[{"fix":"Update import statements from `from glide import ...` to `from glide_sync import ...` for synchronous client components.","message":"In version 2.1, the Python package structure underwent a significant change. Previously, core components might have been accessible directly under `glide`. Now, synchronous client classes are specifically under `glide_sync`, and shared components are under `glide_shared`. This change can break existing imports if not updated.","severity":"breaking","affected_versions":">=2.1.0"},{"fix":"Always use `pip install valkey-glide-sync` and `from glide_sync import ...` for synchronous operations, or `pip install valkey-glide` and `from glide import ...` for asynchronous operations.","message":"Valkey GLIDE offers both synchronous (`valkey-glide-sync`) and asynchronous (`valkey-glide`) Python clients. Ensure you install and import from the correct package (`glide_sync` for sync, `glide` for async) based on your application's concurrency model. Mixing them or using the wrong package can lead to unexpected behavior or `AttributeError`s.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Append `.get()` to all command calls to synchronously retrieve their results, e.g., `value = client.get('key').get()`.","message":"When executing commands with the synchronous client, the methods return a future-like object. You must explicitly call `.get()` on the result of a command (e.g., `client.ping().get()`) to retrieve the actual value or wait for completion. Failing to do so will result in an unawaited future object.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Instantiate `GlideClient` for standalone servers and `GlideClusterClient` for cluster environments, ensuring the configuration matches the deployment type.","message":"For cluster deployments, you must use `GlideClusterClient` and `GlideClusterClientConfiguration`. For standalone deployments, use `GlideClient` and `GlideClientConfiguration`. Using the wrong client type for your Redis/Valkey setup will result in connection or command execution errors.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Design your application to initialize OpenTelemetry tracing and metrics once at startup. For configuration changes, a process restart is required.","message":"OpenTelemetry configuration can only be initialized once per process. If you need to change OpenTelemetry settings, your application must be restarted to apply the new configuration.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}