Skip to content

This is a simple redis client that implements some of the commands of redis.

Notifications You must be signed in to change notification settings

YuanInCode/rc-redis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 

Repository files navigation

A simple redis client

This is a simple redis client that implements some of the commands of redis.

This redis client also supports connection pool, if you need to use pool, please add apache-commons-pool2 dependency in your project pom.xml:

<dependency>
    <groupId>org.apache.commons</groupId>
    <artifactId>commons-pool2</artifactId>
    <version>2.11.1</version>
</dependency>

How to use

  1. The usage of Redis:
// without password
Redis redis = RedisBuilder.builder()
        .host("localhost")
        .port(6379)
        .build();
try {
    redis.set("name", "tom");
} finally {
    redis.close();
}

// with password
Redis redis = RedisBuilder.builder()
        .host("localhost")
        .port(6379)
        .password("123456")
        .build();
try {
    redis.set("name", "tom");
} finally {
    redis.close();
}
  1. The usage of PooledRedis
RedisPool pool = RedisPoolBuilder.builder()
        .host("localhost")
        .port(6379)
        .password("123456")
        .maxTotal(8)
        .maxIdle(4)
        .minIdle(1)
        .testOnBorrow(true)
        .build();
PooledRedis pooledRedis = new PooledRedis(pool);
try {
    pooledRedis.set("name", "jerry");
} finally {
    pooledRedis.close();
}

About

This is a simple redis client that implements some of the commands of redis.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages