Redis3.0的Python集群客户端:redis-py-cluster

jopen 10年前

Python的集群客户端官方集群支持针对Redis的3.0。 这个项目是 redis-rb-cluster的一个移植,并增加许多附加功能。

依赖和支持的Python版本

  • redis >= 2.9.1
  • Cluster enabled redis servers. Only Redis 3.0 beta.7 and above is supported because of CLUSTER SLOTS command was introduced in that release.

Current python support is

  • 2.7 + hiredis
  • 3.2 + hiredis
  • 3.3 + hiredis
  • 3.4 + hiredis

使用示例

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 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'

项目主页:http://www.open-open.com/lib/view/home/1414847889512