Git Product home page Git Product logo

deerlet-redis-client's Introduction

deerlet-redis-client

deerlet是一个简单易用的redis for java客户端,支持与spring无缝集成。

特性

========================================================== 1,轻量级,jar包只有25kb。
2,简单易用,无侵入性。
3,可以与当前流行的ioc容器spring无缝集成。
4,API完全与redis命令保持一致,减少学习成本。
5,支持集群,采用一致性hash策略。

maven依赖坐标

<dependency>
    <groupId>com.zuoxiaolong</groupId>
    <artifactId>deerlet-redis-client</artifactId>
    <version>1.1</version>
</dependency>

使用示例(直接使用)

1.在classpath(比如eclipse中src下)路径下添加以下文件,名为deerlet.properties

========================================================== #该属性为redis服务器ip和端口,支持集群,以逗号隔开
address=localhost:6379

2.使用以下编程式的方式即可使用deerlet

Configuration configuration = ConfigurationFactory.create().loadConfiguration();
ConnectionFactory connectionFactory = new ConnectionFactoryImpl(configuration);
DeerletRedisClient deerletRedisClient = new DeerletRedisClientImpl(connectionFactory);//获取client对象

deerletRedisClient.set("testKey","testValue");//存储一个键为testKey,值为testValue的键值对
System.out.println(deerletRedisClient.get("testKey"));//获取
System.out.println(deerletRedisClient.dbSize());//查看大小
deerletRedisClient.flushAll();//刷新
System.out.println(deerletRedisClient.dbSize());//查看大小

使用示例(与spring集成)

1.在spring的配置文件中加入如下bean定义

========================================================== <bean id="deerletRedisClient" class="com.zuoxiaolong.deerlet.redis.client.spring.DeerletRedisClientFactoryBean">
</bean>

2.在classpath(比如eclipse中src下)路径下添加以下文件,名为deerlet.properties

========================================================== #该属性为redis服务器ip和端口,支持集群,以逗号隔开
address=localhost:6379

3.使用以下编程式的方式即可使用deerlet

ApplicationContext applicationContext = new FileSystemXmlApplicationContext("
classpath:applicationContext.xml");//初始化spring容器
DeerletRedisClient deerletRedisClient = applicationContext.getBean(DeerletRedisClient.class);//获取client对象

deerletRedisClient.set("testKey","testValue");//存储一个键为testKey,值为testValue的键值对
System.out.println(deerletRedisClient.get("testKey"));//获取
System.out.println(deerletRedisClient.dbSize());//查看大小
deerletRedisClient.flushAll();//刷新
System.out.println(deerletRedisClient.dbSize());//查看大小

deerlet.properties文件属性说明

address:必选,格式为 host1:port1,host2:port2....
initSize:可选,指定连接池初始连接数,默认为10
maxSize:可选,指定连接池最大连接数,默认为100
minIdleSize:可选,指定连接池最小空闲连接数,默认为10
maxIdleSize:可选,指定连接池最大空闲连接数,默认为20

目前支持的命令

del,dump,exists,expire,expireat,keys,migrate,move,object,persist,pexpire
,pexpireat,pttl,randomkey,rename,renamenx,restore,sort,ttl,type,scan
,append,bitcount,bitop,decr,decrby,get,getbit,getrange,getset,incr,incrby
,incrbyfloat,mget,mset,msetnx,psetex,set,setbit,setex,setnx,setrange,strlen
,lindex,linsert,llen,lpop,lpush,lpushx,lrange,lrem,lset,ltrim
,select,bgrewriteaof,bgsave,dbsize,flushall,flushdb
...正在陆续添加中...欢迎您来一起加入

如何加入我们

1, 首先安装一下git,并将代码clone到本地,切换到1.X分支
git clone [email protected]:xiaolongzuo/deerlet-redis-client.git //下载源码
2, 在本地电脑上下载并安装maven,或使用eclipse的maven插件都可以,因为deerlet的构建工具是maven
3, 在本地电脑上安装redis,并启动三个redis实例,端口分别为6379,6479,6666
4, redis启动以后,运行mvn test命令看是否能够通过单元测试
5, 测试通过后,即可进行开发,欢迎提交PR.

deerlet-redis-client's People

Contributors

xiaolongzuo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

deerlet-redis-client's Issues

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.