Python Operation Redis Cluster

Source: Internet
Author: User
Tags redis cluster install redis

Redis Cluster


./redis-trib.rb Create--replicas 1 ip1:7000 ip1:7001

Cluster info/nodes

Redis-cli-c-H yourhost-p yourpost


Pip Install Redis-py-cluster

PIP Upgrade pip-9.0.1.tar.gz

# !/usr/bin/env python# coding:utf-8# import redisfrom rediscluster import  strictredisclusterimport sysredis_nodes =  [{' host ': ' Ip1 ', ' Port ':7000}]try:     redisconn = strictrediscluster (startup_nodes=redis_nodes) Except Exception,e:     print  "connect error!"     sys.exit (1) redisconn.set (' name ',  ' admin ') redisconn.set (' age ',  18) print  "name is: ",  redisconn.get (' name ') print  "age  is: ",  redisconn.get (' Age ')   Install the redis  server and the python  redis  Library (Pip install redis) on your computer. Create a redis  hash table test that contains the fields count (1)   and name (' Fester bestertester '), which outputs all fields of test . # redisconn.hmset (' Test ',  {' count ': 1,  ' name ':  ' Fester bestertester '}) print  redisconn.hgetall (' test ')   Auto-test  count  field and output it. >>> conn.hincrby (' Test ',  ' count ',  3) 4>>> conn.hget (' Test ',  ' count ') B ' 4 ' 

This article is from the "Python Operation" blog, declined reprint!

Python Operation Redis Cluster

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.