[![Build Status](https://github.com/andgineer/redis-redirect/workflows/ci/badge.svg)](https://github.com/andgineer/redis-redirect/actions)
[![Coverage](https://raw.githubusercontent.com/andgineer/redis-redirect/python-coverage-comment-action-data/badge.svg)](https://htmlpreview.github.io/?https://github.com/andgineer/redis-redirect/blob/python-coverage-comment-action-data/htmlcov/index.html)
# (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:
1) Your Redis configuration is incorrect. In this case, you should fix your Redis settings,
`redis-redirect` cannot help you in this scenario.
2) 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.
3) 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
* [Codecov](https://app.codecov.io/gh/andgineer/redis-redirect/tree/master/src%2Fredis_redirect)
* [Coveralls](https://coveralls.io/github/andgineer/redis-redirect)
Raw data
{
"_id": null,
"home_page": "https://github.com/andgineer/redis-redirect",
"name": "redis-redirect",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "redis asyncio wrapper",
"author": "Andrey Sorokin",
"author_email": "andrey@sorokin.engineer",
"download_url": "https://files.pythonhosted.org/packages/39/d4/71b6dea2851c64af55e3a1aeca9d73759bbb44a6ed0106ae1897c28afa92/redis_redirect-0.1.8.tar.gz",
"platform": null,
"description": "[![Build Status](https://github.com/andgineer/redis-redirect/workflows/ci/badge.svg)](https://github.com/andgineer/redis-redirect/actions)\n[![Coverage](https://raw.githubusercontent.com/andgineer/redis-redirect/python-coverage-comment-action-data/badge.svg)](https://htmlpreview.github.io/?https://github.com/andgineer/redis-redirect/blob/python-coverage-comment-action-data/htmlcov/index.html)\n# (aio)REDIS wrapper to deal with cluster redirect exceptions `MOVED`\n\nLike\n\n redis.exceptions.ResponseError: MOVED 4085 10.213.192.152:6379\n\nWhen Redis returns a MOVED exception, it indicates that the client should repeat its request for the specified host.\n\nThis exception can occur in the following situations:\n\n1) Your Redis configuration is incorrect. In this case, you should fix your Redis settings,\n`redis-redirect` cannot help you in this scenario.\n2) You are connecting to the wrong host.\nFor instance, if you're using Amazon managed Redis (ElastiCache), Amazon provides a fixed\nDNS name for the configuration node and an IP address for the work node. The IP address may change in the future.\nIn such cases, you should just use the DNS name, `redis-redirect` cannot help you in this scenario.\n3) You're using a multi-node Redis cluster.\nIn this case, you can use the `redis-redirect` to automatically switch between Redis nodes or shards.\n\nThe `redis-redirect` is designed to handle `MOVED` exceptions seamlessly and transparently.\n\n# Installation\n\n pip install redis-redirect\n\n# Usage\n\n import redis_redirect\n\n redis = redis_redirect.Redis(host='my-redis.com', port=6379, db=0)\n redis.set('foo', 'bar')\n\n\n# How it works\n\nThe `redis-redirect` is designed to transparently handle Redis server redirection exceptions.\n\nWhen a client sends a request to the Redis server, the `redis-redirect` checks if\nthe server has returned a `MOVED` exception.\n\nIf a `MOVED` exception is received, the `redis-redirect` updates the address of the Redis server and resends\nthe request to the new address.\n\nAfter the `redis-redirect` updates the Redis server address, it transparently forwards subsequent requests to\nthe new Redis server address.\n\n## Coverage report\n* [Codecov](https://app.codecov.io/gh/andgineer/redis-redirect/tree/master/src%2Fredis_redirect)\n* [Coveralls](https://coveralls.io/github/andgineer/redis-redirect)\n",
"bugtrack_url": null,
"license": null,
"summary": "(aio)REDIS wrapper to deal with cluster redirect exceptions (`MOVED`).",
"version": "0.1.8",
"project_urls": {
"Homepage": "https://github.com/andgineer/redis-redirect"
},
"split_keywords": [
"redis",
"asyncio",
"wrapper"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "f5ba21367ba4071303ca9b8194535734df95dbff95f65b6c3e0971b7588c054e",
"md5": "06e5357fef50e5c74f6cc284ec89240f",
"sha256": "046087540d209ba39b0c6eae0627aa62dbb6fe7145cf1b2354a7f399077eaa00"
},
"downloads": -1,
"filename": "redis_redirect-0.1.8-py3-none-any.whl",
"has_sig": false,
"md5_digest": "06e5357fef50e5c74f6cc284ec89240f",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 6855,
"upload_time": "2024-05-28T16:27:12",
"upload_time_iso_8601": "2024-05-28T16:27:12.096537Z",
"url": "https://files.pythonhosted.org/packages/f5/ba/21367ba4071303ca9b8194535734df95dbff95f65b6c3e0971b7588c054e/redis_redirect-0.1.8-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "39d471b6dea2851c64af55e3a1aeca9d73759bbb44a6ed0106ae1897c28afa92",
"md5": "2164511ca8df29384976333a45e62eff",
"sha256": "460bf39aa858aa3f95a0284823a9bc32ea6a3088abb03a95721a2f80cf554291"
},
"downloads": -1,
"filename": "redis_redirect-0.1.8.tar.gz",
"has_sig": false,
"md5_digest": "2164511ca8df29384976333a45e62eff",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 6726,
"upload_time": "2024-05-28T16:27:14",
"upload_time_iso_8601": "2024-05-28T16:27:14.101553Z",
"url": "https://files.pythonhosted.org/packages/39/d4/71b6dea2851c64af55e3a1aeca9d73759bbb44a6ed0106ae1897c28afa92/redis_redirect-0.1.8.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-05-28 16:27:14",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "andgineer",
"github_project": "redis-redirect",
"travis_ci": false,
"coveralls": true,
"github_actions": true,
"requirements": [
{
"name": "async-timeout",
"specs": [
[
"==",
"4.0.3"
]
]
},
{
"name": "cffi",
"specs": [
[
"==",
"1.16.0"
]
]
},
{
"name": "cryptography",
"specs": [
[
"==",
"42.0.0"
]
]
},
{
"name": "hiredis",
"specs": [
[
"==",
"2.3.2"
]
]
},
{
"name": "pycparser",
"specs": [
[
"==",
"2.21"
]
]
},
{
"name": "redis",
"specs": [
[
"==",
"5.1.0b3"
]
]
},
{
"name": "types-pyopenssl",
"specs": [
[
"==",
"23.3.0.20240106"
]
]
},
{
"name": "types-redis",
"specs": [
[
"==",
"4.6.0.20240106"
]
]
}
],
"lcname": "redis-redirect"
}