(aio)REDIS wrapper to deal with cluster redirect exceptions (`MOVED`).
Project description
(aio)REDIS wrapper to deal with cluster redirect exceptions MOVED
Like
redis.exceptions.ResponseError: MOVED 4085 10.213.192.152:6379
When Redis returns a MOVED exception, it indicates that the client should repeat its request for the specified host.
This exception can occur in the following situations:
- Your Redis configuration is incorrect. In this case, you should fix your Redis settings,
redis-redirect
cannot help you in this scenario. - You are connecting to the wrong host.
For instance, if you're using Amazon managed Redis (ElastiCache), Amazon provides a fixed
DNS name for the configuration node and an IP address for the work node. The IP address may change in the future.
In such cases, you should just use the DNS name,
redis-redirect
cannot help you in this scenario. - You're using a multi-node Redis cluster.
In this case, you can use the
redis-redirect
to automatically switch between Redis nodes or shards.
The redis-redirect
is designed to handle MOVED
exceptions seamlessly and transparently.
Installation
pip install redis-redirect
Usage
import redis_redirect
redis = redis_redirect.Redis(host='my-redis.com', port=6379, db=0)
redis.set('foo', 'bar')
How it works
The redis-redirect
is designed to transparently handle Redis server redirection exceptions.
When a client sends a request to the Redis server, the redis-redirect
checks if
the server has returned a MOVED
exception.
If a MOVED
exception is received, the redis-redirect
updates the address of the Redis server and resends
the request to the new address.
After the redis-redirect
updates the Redis server address, it transparently forwards subsequent requests to
the new Redis server address.
Coverage report
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 Distribution
Built Distribution
File details
Details for the file redis_redirect-0.1.7.tar.gz
.
File metadata
- Download URL: redis_redirect-0.1.7.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5a50c0201b52793f3cc50981e401944a8ad892f8ea9aa3c92cdea086bfb2fbde |
|
MD5 | f380b9b330ed5e9ed6a94da98daad362 |
|
BLAKE2b-256 | 66b0407124239f5eaf8086a859bc9007d1cdc950104a34e40cf14112940a3f00 |
File details
Details for the file redis_redirect-0.1.7-py3-none-any.whl
.
File metadata
- Download URL: redis_redirect-0.1.7-py3-none-any.whl
- Upload date:
- Size: 3.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5e10bfc64cb2cea0de1f09f03af8aceed70349ec60199f0f26a0ed95bbdb31ed |
|
MD5 | 603a3579134f37a5a81ac06285b8b28d |
|
BLAKE2b-256 | f0134d3e7ecba241f3a9198bea943c8027a37911f034904758fee1a63f9944ce |