Git Product home page Git Product logo

redis-unit's Introduction

Redis Unit

Build Status Build Status Maven Central

Start and stop Redis(v3.2.5) instance for unit testing applications.

Redis unit requires Java 8 at runtime.

Features

  • Redis Server support
  • Redis Master / Slave support
  • Redis Sentinel (+ Redis Master / Slave) support
  • Redis Cluster support

Maven Central

<dependency>
  <groupId>net.ishiis.redis</groupId>
  <artifactId>redis-unit</artifactId>
  <version>1.0.3</version>
  <scope>test</scope>
</dependency>

Usage

Quick start

1, Redis Server

Redis Server listen 6379

RedisServer server = new RedisServer();
server.start();
// do something
server.stop();

2, Redis Master / Slave

Redis Master listen 6379, and Slave listen 6380.

RedisMasterSlave masterSlave = new RedisMasterSlave();
masterSlave.start();
// do something
masterSlave.stop();

3, Redis Sentinel (+ Redis Master / Slave)

Redis Sentinel listen 26379, 26380, 26381.

RedisSentinel sentinel = new RedisSentinel();
sentinel.start();
// do something
sentinel.stop();

4, Redis Cluster

Redis Cluster listen 6379, 6380, 6381.

RedisCluster cluster = new RedisCluster();
cluster.start();
// do something
cluster.stop();

Customize

If you want to customize Redis instances, use RedisConfig.

RedisMasterSlaveConfig master = new RedisMasterSlaveConfig.MasterBuilder(6379)
                                        .redisBinaryPath("/usr/local/bin/redis-server").build();
List<RedisMasterSlaveConfig> slaves = new ArrayList<>();
slaves.add(new RedisMasterSlaveConfig.SlaveBuilder(6380, 6379).redisBinaryPath("/usr/local/bin/redis-server").build());
slaves.add(new RedisMasterSlaveConfig.SlaveBuilder(6381, 6379).redisBinaryPath("/usr/local/bin/redis-server").build());

RedisMasterSlave masterSlave = new RedisMasterSlave(master, slaves);

Development

Requirements

  • Java 8
  • Maven 3.0.0 or higher

First bootstrap and download the wrapper

cd redis_unit_source_dir
./mvnw

Running unit tests

./mvnw test

redis-unit's People

Contributors

ishiis avatar

Watchers

James Cloos avatar Keishi wada avatar  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.