Skip to main content

Cluster library for redis 3.0.0 built on top of redis-py lib

Project description

# Beta notes

Release 0.2.0 of redis-cluster is a Beta release.

Before using this lib please read the documentation and understand the major differences and problems that exists with redis clustering. The following documents is best to read.

  • [Command differences](docs/Commands.md)

  • [Limitations and differences](docs/Limits_and_differences.md)

It is recommended to test this lib in real world scenarios to find problems and areas to improve for next release.

It is NOT recommended to run this lib in production.

If you find any bugs or have ideas for improvment please open a ticket at https://github.com/Grokzen/redis-py-cluster

# redis-py-cluster

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

[![Build Status](https://travis-ci.org/Grokzen/redis-py-cluster.svg?branch=master)](https://travis-ci.org/Grokzen/redis-py-cluster) [![Coverage Status](https://coveralls.io/repos/Grokzen/redis-py-cluster/badge.png)](https://coveralls.io/r/Grokzen/redis-py-cluster) [![Latest Version](https://pypip.in/version/redis-py-cluster/badge.svg)](https://pypi.python.org/pypi/redis-py-cluster/) [![Downloads](https://pypip.in/download/redis-py-cluster/badge.svg)](https://pypi.python.org/pypi/redis-py-cluster/) [![Supported Python versions](https://pypip.in/py_versions/redis-py-cluster/badge.svg)](https://pypi.python.org/pypi/redis-py-cluster/) [![License](https://pypip.in/license/redis-py-cluster/badge.svg)](https://pypi.python.org/pypi/redis-py-cluster/) [![Gitter](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/Grokzen/redis-py-cluster?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Code Health](https://landscape.io/github/Grokzen/redis-py-cluster/unstable/landscape.svg)](https://landscape.io/github/Grokzen/redis-py-cluster/unstable)

## Dependencies & supported python 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.

## Installation

Latest stable release from pypi

` $ pip install redis-py-cluster `

or from source

` $ python setup.py install `

## Usage example

Small sample script that show how to get started with RedisCluster. decode_responses=True is required to have when running on python3.

`python >>> from rediscluster import RedisCluster >>> startup_nodes = [{"host": "127.0.0.1", "port": "7000"}] >>> rc = RedisCluster(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.

  • RedisCluster

  • StrictClusterPipeline

  • ClusterPubSub

## Testing

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](docs/Cluster_Setup.md).

### Tox - Multi environment testing

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 documentation

More detailed documentation can be found in docs folder.

  • [Pubsub](docs/Pubsub.md)

  • [Setup a redis cluster. Manually, Docker & Vagrant](docs/Cluster_Setup.md)

  • [Command differences](docs/Commands.md)

  • [Limitations and differences](docs/Limits_and_differences.md)

  • [Redisco support (Django ORM)](docs/Redisco.md)

  • [Threaded Pipeline support](docs/Threads.md)

  • [Authors](docs/Authors)

## Disclaimer

Both this client and Redis Cluster are a work in progress that is not suitable to be used in production environments. This is only my current personal opinion about both projects.

## License & Authors

MIT (See docs/License.txt file)

The license should be the same as redis-py (https://github.com/andymccurdy/redis-py)

  • 0.2.0
    • Moved pipeline code into new file.

    • Code now uses a proper cluster connection pool class that handles all nodes and connections similar to how redis-py do.

    • Better support for pubsub. All clients will now talk to the same server because pubsub commands do not work reliably if it talks to a random server in the cluster.

    • Better result callbacks and node routing support. No more ugly decorators.

    • Fix keyslot command when using non ascii characters.

    • Add bitpos support, redis-py 2.10.2 or higher required.

    • Fixed a bug where vagrant users could not build the package via shared folder.

    • Better support for CLUSTERDOWN error. (Neuront)

    • Parallel pipeline execution using threads. (72squared)

    • Added vagrant support for testing and development. (72squared)

    • Improve stability of client during resharding operations (72squared)

  • 0.1.0
    • Initial release

    • First release uploaded to pypi

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

redis-py-cluster-0.2.0.tar.gz (21.6 kB view details)

Uploaded Source

File details

Details for the file redis-py-cluster-0.2.0.tar.gz.

File metadata

File hashes

Hashes for redis-py-cluster-0.2.0.tar.gz
Algorithm Hash digest
SHA256 02a418ade33947b814e38847e4a5573613684446db319150ef6a605bf913668a
MD5 0546363d39aafc18271c628c2765a595
BLAKE2b-256 af9e876fc9bd0c4d7ed0dd5aba496c5509955a59e7ea421ac02a9669df932d2e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page