This is the client used to connect directly to a standard Valkey node.
Valkey 8.0 adds CLIENT CAPA redirect for standalone primary/replica
deployments. In valkey-py, this is exposed as the opt-in
client_capa_redirect connection argument.
>>> import valkey
>>> replica = valkey.Valkey(host="localhost", port=6380,
... client_capa_redirect=True)
>>> replica = valkey.from_url(
... "valkey://localhost:6380?client_capa_redirect=true"
... )When enabled, commands sent to a standalone replica raise
valkey.exceptions.RedirectError until READONLY is enabled for that
connection. For more details, see :doc:`advanced_features`.
.. autoclass:: valkey.Valkey :members:
Valkey Sentinel provides high availability for Valkey. There are commands that can only be executed against a Valkey node running in sentinel mode. Connecting to those nodes, and executing commands against them requires a Sentinel connection.
Connection example (assumes Valkey exists on the ports listed below):
>>> from valkey import Sentinel >>> sentinel = Sentinel([('localhost', 26379)], socket_timeout=0.1) >>> sentinel.discover_master('mymaster') ('127.0.0.1', 6379) >>> sentinel.discover_slaves('mymaster') [('127.0.0.1', 6380)]
.. autoclass:: valkey.sentinel.Sentinel
:members:
.. autoclass:: valkey.sentinel.SentinelConnectionPool
:members:
This client is used for connecting to a Valkey Cluster.
.. autoclass:: valkey.cluster.ValkeyCluster
:members:
.. autoclass:: valkey.cluster.ClusterNode
:members:
See complete example: here
This client is used for communicating with Valkey, asynchronously.
.. autoclass:: valkey.asyncio.client.Valkey
:members:
.. autoclass:: valkey.asyncio.cluster.ValkeyCluster
:members:
:member-order: bysource
.. autoclass:: valkey.asyncio.cluster.ClusterNode
:members:
:member-order: bysource
.. autoclass:: valkey.asyncio.cluster.ClusterPipeline
:members: execute_command, execute
:member-order: bysource
See complete example: here
.. autoclass:: valkey.connection.Connection
:members:
.. autoclass:: valkey.asyncio.connection.Connection
:members:
See complete example: here
.. autoclass:: valkey.connection.ConnectionPool
:members:
.. autoclass:: valkey.asyncio.connection.ConnectionPool
:members: