Redis cluster client in python for the official cluster support targeted for redis 3.0.
This project is a port of redis-rb-cluster
by antirez, with alot of added functionality. The original source can be found at https://github.com/antirez/redis-rb-cluster
![Gitter](https://badges.gitter.im/Join Chat.svg)
Please read the following documentation that will go through all changes that is required when upgrading redis-py-cluster
between versions.
- redis >= 2.10.2
- Cluster enabled redis servers. Only Redis 3.0 beta.7 and above is supported because of CLUSTER SLOTS command was introduced in that release.
- Optional: hiredis >= 0.1.3
Hiredis is tested and supported on all supported python versions.
Supported python versions:
- 2.7.x
- 3.2.x
- 3.3.x
- 3.4.1+
Python 3.4.0 do not not work with pubsub because of segfault issues (Same as redis-py has). If rediscluster is runned on 3.4.0 it will raise RuntimeError exception and exit. If you get this error locally when running tox, consider using pyenv
to fix this problem.
Latest stable release from pypi
$ pip install redis-py-cluster
or from source
$ python setup.py install
Small sample script that show how to get started with RedisCluster. decode_responses=True
is required to have when running on python3.
>>> from rediscluster import StrictRedisCluster
>>> startup_nodes = [{"host": "127.0.0.1", "port": "7000"}]
>>> rc = StrictRedisCluster(startup_nodes=startup_nodes, decode_responses=True)
>>> rc.set("foo", "bar")
True
>>> rc.get("foo")
'bar'
The following imports can be imported from redis
package.
StrictRedisCluster
RedisCluster
StrictClusterPipeline
ClusterPubSub
StrictRedisCluster
is based on redis.StrictRedis
and RedisCluster
has the same functionality as redis.Redis
even if it is not directly based on it.
All tests are currently built around a 6 redis server cluster setup (3 masters + 3 slaves). One server must be using port 7000 for redis cluster discovery.
The easiest way to setup a cluster is to use either a Docker or Vagrant. They are both described in Setup a redis cluster. Manually, Docker & Vagrant.
Tox is the easiest way to run all tests because it will manage all dependencies and run the correct test command for you.
TravisCI will use tox to run tests on all supported python & hiredis versions.
Install tox with pip install tox
To run all environments you need all supported python versions installed on your machine. (See supported python versions list) and you also need the python-dev package for all python versions to build hiredis.
To run a specific python version use either tox -e py27
or tox -e py34
More detailed documentation can be found in docs
folder.
- Benchmarks
- Pubsub
- Setup a redis cluster. Manually, Docker & Vagrant
- Command differences
- Limitations and differences
- Redisco support (Django ORM)
- Pipelines
- Threaded Pipeline support
- Authors
Both Redis cluster and redis-py-cluster is considered stable and production ready.
But this depends on what you are going to use clustering for. In the simple use cases with SET/GET and other single key functions there is not issues. If you require multi key functinoality or pipelines then you must be very carefull when developing because they work slightly different from the normal redis server.
If you require advance features like pubsub or scripting, this lib and redis do not handle that kind of use-cases very well. You either need to develop a custom solution yourself or use a non clustered redis server for that.
Finally, this lib itself is very stable and i know of atleast 2 companies that use this in production with high loads and big cluster sizes.
MIT (See docs/License.txt file)
The license should be the same as redis-py (https://github.com/andymccurdy/redis-py)