Coder Social home page Coder Social logo

wagnermatos / lettuce-core Goto Github PK

View Code? Open in Web Editor NEW

This project forked from redis/lettuce

0.0 1.0 0.0 8.63 MB

Advanced Redis client for thread-safe sync, async, and reactive usage. Supports Cluster, Sentinel, Pipelining, and codecs.

Home Page: https://lettuce.io

License: Apache License 2.0

Makefile 0.33% Shell 0.11% Java 99.56%

lettuce-core's Introduction

lettuce - Advanced Java Redis client

Build Status codecov Maven Central

Lettuce is a scalable thread-safe Redis client for synchronous, asynchronous and reactive usage. Multiple threads may share one connection if they avoid blocking and transactional operations such as BLPOP and MULTI/EXEC. lettuce is built with netty. Supports advanced Redis features such as Sentinel, Cluster, Pipelining, Auto-Reconnect and Redis data models.

This version of lettuce has been tested against the latest Redis source-build.

See the Wiki for more docs.

Communication

Documentation

Binaries/Download

Binaries and dependency information for Maven, Ivy, Gradle and others can be found at http://search.maven.org.

Releases of lettuce are available in the maven central repository. Take also a look at the Download page in the Wiki.

Example for Maven:

<dependency>
  <groupId>biz.paluch.redis</groupId>
  <artifactId>lettuce</artifactId>
  <version>x.y.z</version>
</dependency>

Using Snapshots:

<dependency>
  <groupId>biz.paluch.redis</groupId>
  <artifactId>lettuce</artifactId>
  <version>x.y.z</version>
</dependency>

<repositories>
  <repository>
    <id>sonatype-nexus-snapshots</id>
    <url>https://oss.sonatype.org/content/repositories/snapshots</url>
    <snapshots>
      <enabled>true</enabled>
    </snapshots>
  </repository>
</repositories>

Shaded JAR-File (packaged dependencies and relocated to the com.lambdaworks package to prevent version conflicts)

<dependency>
  <groupId>biz.paluch.redis</groupId>
  <artifactId>lettuce</artifactId>
  <version>x.y.z</version>
  <classifier>shaded</classifier>
  <exclusions>
    <exclusion>
      <groupId>io.reactivex</groupId>
      <artifactId>rxjava</artifactId>
    </exclusion>
    <exclusion>
      <groupId>org.latencyutils</groupId>
      <artifactId>LatencyUtils</artifactId>
    </exclusion>
    <exclusion>
      <groupId>io.netty</groupId>
      <artifactId>netty-common</artifactId>
    </exclusion>
    <exclusion>
      <groupId>io.netty</groupId>
      <artifactId>netty-transport</artifactId>
    </exclusion>
    <exclusion>
      <groupId>io.netty</groupId>
      <artifactId>netty-handler</artifactId>
    </exclusion>
    <exclusion>
      <groupId>io.netty</groupId>
      <artifactId>netty-codec</artifactId>
    </exclusion>
    <exclusion>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
    </exclusion>
    <exclusion>
      <groupId>io.netty</groupId>
      <artifactId>netty-transport-native-epoll</artifactId>
    </exclusion>
    <exclusion>
      <groupId>org.apache.commons</groupId>
      <artifactId>commons-pool2</artifactId>
    </exclusion>
  </exclusions>
</dependency>

or snapshots at https://oss.sonatype.org/content/repositories/snapshots/

Basic Usage

RedisClient client = RedisClient.create("redis://localhost");
StatefulRedisConnection<String, String> connection = client.connect();
RedisStringCommands sync = connection.sync();
String value = sync.get("key");

Each Redis command is implemented by one or more methods with names identical to the lowercase Redis command name. Complex commands with multiple modifiers that change the result type include the CamelCased modifier as part of the command name, e.g. zrangebyscore and zrangebyscoreWithScores.

See Basic usage for further details.

Asynchronous API

StatefulRedisConnection<String, String> connection = client.connect();
RedisStringAsyncCommands<String, String> async = connection.async();
RedisFuture<String> set = async.set("key", "value");
RedisFuture<String> get = async.get("key");

async.awaitAll(set, get) == true;

set.get() == "OK";
get.get() == "value";

See Asynchronous API for further details.

Reactive API

StatefulRedisConnection<String, String> connection = client.connect();
RedisStringReactiveCommands<String, String> reactive = connection.reactive();
Observable<String> set = reactive.set("key", "value");
Observable<String> get = reactive.get("key");

set.subscribe();

get.toBlocking().single() == "value";

See Reactive API for further details.

Pub/Sub

RedisPubSubCommands<String, String> connection = client.connectPubSub().sync();
connection.addListener(new RedisPubSubListener<String, String>() { ... });
connection.subscribe("channel");

Building

Lettuce is built with Apache Maven. The tests require multiple running Redis instances for different test cases which are configured using a Makefile. All tests run against Redis branch 3.0

To build:

$ git clone https://github.com/lettuce-io/lettuce-core.git
$ cd lettuce/
$ make prepare ssl-keys
$ make test
  • Initial environment setup (clone and build redis): make prepare
  • Setup SSL Keys: make ssl-keys
  • Run the build: make test
  • Start Redis (manually): make start
  • Stop Redis (manually): make stop

Bugs and Feedback

For bugs, questions and discussions please use the GitHub Issues.

License

Contributing

Github is for social coding: if you want to write code, I encourage contributions through pull requests from forks of this repository. Create Github tickets for bugs and new features and comment on the ones that you are interested in and take a look into CONTRIBUTING.md

lettuce-core's People

Contributors

changeworld avatar codingfabian avatar danhyun avatar dowenliu-xyz avatar gitter-badger avatar hellyguo avatar jongyeol avatar kichik avatar kleinron avatar mp911de avatar mzapletal avatar odiszapc avatar sebastienbenazet avatar sergey-ushakov avatar shisashi avatar taer avatar wg 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.