Coder Social home page Coder Social logo

codisclient's Introduction

Codis-Client

介绍

codis-client是codis集群的客户端,支持C++,Java,Python

环境依赖 (Python)

1.redis-py-2.4(修复了源码中的一个connection的bug)
2.zkpython-0.4.2
3.zookeeper-c

Install java

cd jodis 
mvn package

Install python

	cd zookeeper-3.4.6/src/c/
	./configure
	make
	make install
	cd redis-py-2.4
	python setup.py install
	cd zkpython-0.4.2
	python setup.py install	

C++ Demo

Python Demo

	import codis_client
	
	#simple example
	codis_client.InitFromZK('127.0.0.1:2181', '/zk/codis/db_test/proxy', "businessID")
	print codis_client.GetProxy().set("kk", "vv")

	#better example
	#if faild, then get other proxy connection
	codis_client.InitFromZK('127.0.0.1:2181', '/zk/codis/db_test/proxy', "businessID")
	try:
		ret = codis_client.GetProxy().set("kk", "vv")
	except redis.exceptions.ConnectionError, e:
		ret = codis_client.GetProxy().set("kk", "vv")

	#best example
	#if faild, reconnect other proxy util success
	codis_client.InitFromZK('127.0.0.1:2181', '/zk/codis/db_test/proxy', "businessID")
	while True:
		try:
			ret = codis_client.GetProxy().set("kk", "vv")
		except redis.exceptions.ConnectionError, e:
			continue
		break

Java Demo

	JedisResourcePool jedisPool = new RoundRobinJedisPool("zkserver:2181", 30000, "/zk/codis/db_xxx/proxy", new JedisPoolConfig());
	try (Jedis jedis = jedisPool.getResource()) {
    		jedis.set("foo", "bar");
    		String value = jedis.get("foo");
	}

codisclient's People

Contributors

weim0000 avatar

Stargazers

simonhe avatar

Watchers

James Cloos avatar  avatar

codisclient's Issues

ImportError: No module named codis_client

您好!

我下载了zookeeper-3.4.6,执行了:
cd zookeeper-3.4.6/src/c/
./configure
make
make install

之后下载了CodisClient,执行了:
cd CodisClient/python/redis-py-2.4/
python setup.py install
cd ../zkpython-0.4.2/
python setup.py install

打开python的command line,执行 import redis 是可以的,并已经成功测试一个redis_server。但是执行import codis_client的时候,会报错误:
Traceback (most recent call last):
File "", line 1, in
ImportError: No module named codis_client

请问是哪个环境没有配置好?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.