Giter Club home page Giter Club logo

codisclient's Introduction

Codis-Client

介绍

codis-client是codis集群的客户端,支持C++,Java,Python, java客户端是基于jodis写的,codis-client在每个key前面加了businessID以区分不同的业务。

环境依赖 (Python)

1.redis-py-2.7.2
2.hiredis(easy_install  hiredis)-0.2.0
3.gcc-4.6.3
4.jdk1.7
5.python2.7
6.kazoo

Install java

cd java
mvn package
生成包为/target/bfdjodis-0.1.2-jar-with-dependencies.jar

Install python

	import BfdCodis

C++ Demo

	#include "BfdCodis.h"
	
	//param[1]  zkAddr codis依赖的zookeeper的地址
	//param[2]  proxyPath codis在zookeeper中的proxy的path
	//param[3]  businessID 业务分类
	BfdCodis pool("192.168.161.22:2181", "/zk/codis/db_test/proxy", "item");
	
	pool.set("kk", "vv");
	string value = pool.get("kk");
	
	新增加超时机制
	int timeout = 50
	pool.set("kk","vv",timeout)
	注:timeout为int型,单位毫秒,两种方式均可用,在不传入timeout时,没有超时时间

Python Demo

	import BfdCodis as codis
	
	//param[1]  zkAddr codis依赖的zookeeper的地址
	//param[2]  proxyPath codis在zookeeper中的proxy的path
	//param[3]  businessID 业务分类
	client = codis.BfdCodis("192.168.161.22:2181", "/zk/codis/db_test23/proxy", "item")
	
	print client.set("key", "value")
	value = client.get("key")

Java Demo

	//param[1]  zkAddr codis依赖的zookeeper的地址
	//param[2]	zkTimeout 连接zookeeper的超时时间
	//param[3]  proxyPath codis在zookeeper中的proxy的path
	//param[4]  config JedisPool的配置信息
	//param[5]  timeout  从JedisPool获取连接的超时时间
	//param[6]  businessID 业务分类
	
	JedisPoolConfig config = new JedisPoolConfig();
	config.setMaxTotal(1000);
	config.setMaxIdle(1000);
	
	BfdJodis bfdjodis = new BfdJodis("192.168.161.22:2181", 3000, "/zk/codis/db_test23/proxy",
		config, 3000, "bfd");
    String str = bfdjodis.set("k1","v1");
	String str = bfdjodis.get("k1");

codisclient's People

Contributors

abigbigbird avatar typhoonzero avatar weim0000 avatar

Watchers

 avatar

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.